Skip to content

Commit

Permalink
Rearanged The Furniture
Browse files Browse the repository at this point in the history
Mostly moved things slightly and edited for flow. Added a code description page
  • Loading branch information
biomurph committed Dec 11, 2017
1 parent 72218b3 commit 17ed0b1
Show file tree
Hide file tree
Showing 8 changed files with 138 additions and 29 deletions.
File renamed without changes
Binary file added Images/outputType.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added Images/screenshot-threshold-arrows.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
20 changes: 20 additions & 0 deletions Installing Pulse Sensor Playground.md
@@ -0,0 +1,20 @@
## Installing the Pulse Sensor Playground 🤓 
1. On the right side of this repository, click on the green `Clone or Download ZIP` button and select `Download ZIP`. Save the `.zip` file to your computer.

<img src="https://cdn.shopify.com/s/files/1/0100/6632/files/Download_Playground_ZIP_1024x1024.png?v=1510864702" width="400">

2. Open up the Arduino IDE.

(**NOTE** If you do not have Arduino, you can download it [here](https://www.arduino.cc/en/Main/Software))

3. Select `Sketch > Include Library > Add .ZIP Library...`

<img src="https://cdn.shopify.com/s/files/1/0100/6632/files/Add_ZIP_LIbrary_1024x1024.png?v=1510865023" width="400">

5. Navigate to the location where you downloded the `.zip` file to install this library.
6. Hurray! Once this library is installed you will see the projects in Arduino's dropdown!
(**NOTE** you may need to restart Arduino)

Now you can select any of the example sketches to get started! Go to [PulseSensor.com](https://pulsesensor.com/) and click on the `PROJECTS` link to find tutorials that go with these code examples!

![menu pulldown](images/menupulldown.png)
90 changes: 90 additions & 0 deletions PulseSenaor Playground Tools.md
@@ -0,0 +1,90 @@
# PulseSensor Playground Tools

We Created the PulseSensor Playground Library to make it easier to use and customize. This page will show you how to get the most out of the PulseSensor Playground. Let's go!

## Pulse Sensor Interrupts

We use interrups in our Pulse Sensor code so that we can get super accurate hear rate data: Beats Per Minute (BPM), and Interbeat Interval (IBI). In order to do that with our Playground library, we have to tell that to Arduino. In the example Sketch

PulseSensor_BPM

there are a couple of lines of code at the very top of the sketch that do this:

#define USE_ARDUINO_INTERRUPTS true
#include <PulseSensorPlayground.h>

While using interrupts is super cool and useful, it won't work with all of the myriad Arduino boards out there. If your board does not support interrupts yet, not to worry! We have code that works just as well without employing interrupts. It's called

PulseSensor_BPM_Alternative

and you can find it in our examples folder inside our library.

## Selecting Your Serial Output

The sketch examples in PulseSensor Playground will output different kinds of serial info for visualizing your pulse waveform and Beats Per Minute data. Here's how you can choose which serial to use.

* Our basic example sketch called `A_StarterProject_and_SignalTester.ino` will output a serial stream of Pusle Sensor signal data only. The signal is read in the loop function about every 10mS. This works perfectly with the Arduino Serial Plotter. Follow this [Tutorial](https://pulsesensor.com/pages/code-and-guide) to give it a go.

* All the other example sketches that we have give you the option to output to the Arduino Serial Plotter, or to our [Pulse Sensor Visualizer](https://github.com/WorldFamousElectronics/PulseSensor_Amped_Processing_Visualizer) program. To select which one you want to output to, you will need to tell Arduino by setting the value of a variable called `outputType` at the top of the sketch. Here's an example of how to set the output to work with our Visualizer software.

![outputType](images/outputType.png)

## Useful Functions

The PulseSensor Playground library exposes some very useful functions for you to use for finding the heartbeat, and getting data into your sketch to make magic with. The descriptions below are brief for brevity. There's much more detail commented in the Playground code files.

### PulseSensorPlayground()
Creates an instance that can access all the PulseSensor Playground functions

PulseSensorPlayground pulseSensor;

Alternately can set up to read multiple Pulse Sensors

const int PULSE_SENSOR_COUNT = 2;
PulseSensorPlayground pulseSensor(PULSE_SENSOR_COUNT);


### begin()
Start reading and processing data from the Pulse Sensor!

### sawNewSample()
Will return `true` if a new sample has been read.

### analogInput(int)
Set the pin your Pulse Sensor is connected to.

### blinkOnPulse(int)
Set the pin that will blink to your pulse.

### fadeOnPulse(int)
Set the pin to fade with you're heartbeat. Make sure the pin can do PWM!

### setSerial(Serial)
The Playround doesn't output serial data automatically. If you want to output serial pulse data, call this. If not, don't.

### setOutputType(int)
By default, Playground output is in `SERIAL_PLOTTER` format. You can change this to `PROCESSING_VISUALIZER` if you like.

### setThreshold(int)
Set a value that the Pulse Sensor signal has to cross. This can be useful to combat noise.

### getLatestSample()
Returns the most recently read analog value from the Pulse Sensor (range: 0..1023).

### getBeatsPerMinute()
Returns the latest beats-per-minute.

### getInterBeatIntervalMs()
Returns the latest interbeat interval (IBI) in milliseconds.

### sawStartOfBeat()
Returns true if a new heartbeat (pulse) has been detected.

### isInsideBeat()
Returns true for the time when a measured heartbeat wave above the `THRESHOLD` value.

### outputSample()
Output the latest sample. If your Sketch wants to plot samples, it should call this function every so often.

###outputBeat()
Output over Serial the latest BPM and IBI values
55 changes: 27 additions & 28 deletions README.md
Expand Up @@ -9,67 +9,66 @@ This Playground is a collection of code of the most popular uses of PulseSensor
- Switch between projects right in the Arduino IDE (software). 💻
- Contritube your projects code back to the GitHub hive-mind. 🐝
```
___
---
## Install the PulseSensor Playground Library

We put together a [handy guide](https://github.com/WorldFamousElectronics/PulseSensorPlayground/blob/master/Installing Pulse Sensor Playground.md) to walk you through getting setup with Arduino and our Pulse Sensor code.

---
## Playground Project Descriptions:


### Start Here:
Plug your sensor in for the first time! Blink an LED with your pulse, live.
- Project Page: https://pulsesensor.com/pages/code-and-guide

- [**Project Page**](https://pulsesensor.com/pages/code-and-guide)

<img src="https://cdn.shopify.com/s/files/1/0100/6632/files/PulseSensor_GettingStarted_bb_1024x1024.png?v=1511986616" width="400">
---

### Calculate BPM:
Focus-in on the code that calculates a user's HeartRate Beats Per Minute, "BPM".
Plug your sensor in for the first time! See the best practises to get the best signal.
- Project Page: https://pulsesensor.com/pages/getting-advanced

- [**Project Page**](https://pulsesensor.com/pages/getting-advanced)

<img src="https://cdn.shopify.com/s/files/1/0100/6632/files/PulseSensor_GettingAdvanced_bb_1024x1024.png?v=1511986194" width="400">
---

### Make A Sound to a live Heartbeat:
Transform the heartbeat into a live "beep" with a speaker and piezo buzzer.
- Project Page: https://pulsesensor.com/pages/pulse-sensor-speaker-tutorial
Transform the heartbeat into a live "beep" with a speaker.

- [**Project Page**](https://pulsesensor.com/pages/pulse-sensor-speaker-tutorial)

<img src="https://cdn.shopify.com/s/files/1/0100/6632/files/PulseSensor_Speaker_bb_61a0333f-e868-4123-961d-7456a31fa928_1024x1024.png?v=1510863829" width="400">
---

### Move a Motor to a live Heartbeat:
Get detailed visulization of the heart's pulse and behavior. Take the PulseSensor date into Processing.
- Project Page: https://pulsesensor.com/pages/pulse-sensor-servo-tutorial
### Move a Motor to a live Heartbeat:
Make a servo motor pulse to your live heartbeat.

- [**Project Page**](https://pulsesensor.com/pages/pulse-sensor-servo-tutorial)

<img src="https://cdn.shopify.com/s/files/1/0100/6632/files/PulseSensor_Servo_bb_87fce9fc-dc47-4208-b708-a7edb6df58a2_1024x1024.png?v=1510863990" width="400">
---


### Processing Visualizer:
### Processing Visualizer:

Get detailed visulization of the heart's pulse and behavior. Take the PulseSensor date into Processing.
- Project Page: https://pulsesensor.com/pages/getting-advanced

- [**Project Page**](https://pulsesensor.com/pages/getting-advanced)

<img src="https://cdn.shopify.com/s/files/1/0100/6632/files/ScreenShot_1024x1024.png?v=1491857113" width="400">
---

### TroubleShoot Your Signal:
Plug your sensor in for the first time! Blink an LED with your pulse, live.
- Project Page: https://pulsesensor.com/pages/code-and-guide
If you're having trouble seeing a heartbeat, make sure that you are using 'Goldilocks' pressure on the Pulse Sensor: Not too hard, not too soft. Squeezing the Pulse Sensor too hard against your skin will make the heartbeat go away, and not enough pressure will cause too much noise to creep in!

<img src="https://github.com/WorldFamousElectronics/PulseSensorStarterProject/blob/master/screenshot-threshold-arrows.png" width="400">


---
## Installing the Arduino Playground 🤓 
1. On the right side, click on the Clone or Download ZIP.
2. Install the PulseSensor Playground library into your Arduino libraries folder.
<img src="https://cdn.shopify.com/s/files/1/0100/6632/files/Download_Playground_ZIP_1024x1024.png?v=1510864702" width="400">

3. In the IDE, Select Sketch / Include Library / Add .ZIP Library...
4. In the resulting dialog, navigate to the downloaded .ZIP of this library.
<img src="https://cdn.shopify.com/s/files/1/0100/6632/files/Add_ZIP_LIbrary_1024x1024.png?v=1510865023" width="400">

5. Follow the instructions to install this library.
6. Hurray! Once this library is installed you will see the projects in Arduino's dropdown!
<img src="https://github.com/yury-g/PulseSensorPlayground/blob/master/menupulldown.png" width="400">
If you are seeing way too many Beats Per Minute, or you are getting lots of noise, try adjusting the `Threshold` setting. The Threshold variable tells Arduino when to find a pulse that is legit. Adjust this number (noted below with arrows) up for less sensitivity and down for more sensitivity. In the [**StarterProject**](https://pulsesensor.com/pages/code-and-guide) you can find the Threshold variable as shown in the pic below:

![StarterThreshold](images/screenshot-threshold-arrows.png)

In the other examples, the `THRESHOLD` is defined at the top of the code.

---
## Connecting the Harware 😎
Expand Down
1 change: 0 additions & 1 deletion examples/PulseSensor_BPM/PulseSensor_BPM.ino
Expand Up @@ -101,7 +101,6 @@ void setup() {
delay(50);
}
}
// pulseSensor.setThreshold(550);
}

void loop() {
Expand Down
1 change: 1 addition & 0 deletions examples/TwoPulseSensors_On_OneArduino/README.md
@@ -0,0 +1 @@
# Multiple Sensor Guide coming soon...

0 comments on commit 17ed0b1

Please sign in to comment.