Pulse Sensor Servo Tutorial

This tutorial will show you how to attach a Servo motor to your Arduino and use Pulse Sensor to make it move to your heartbeat!

 

 

Here's a list of materials for this tutorial

Our Pulse Sensor Arduino code is designed to find the moment of heart beat in the pulse waveform for accurate BPM calculation. Go to the Pulse Sensor Playground README for instructions on installing the Pule Sensor Playground Library in Arduino.

First step is to build the circuit. In this example, we are going to use the built-in LED fade functionality of the Pulse Sensor Playground Library. The LED fade is driven on digital pin 5. Connect pin 5 to the Anode of the LED (LONG lead) and then connect the Cathode (SHORT lead) to one lead of a 1K Resistor [Brown|Black|Red color code] and the other resistor lead to the GND rail of your breadboard. NOTE: you should use at least a 470 ohm resistor for the fade LED or you will see some weird behavior! You will also need to connect the Arduino UNO GND pin to the GND (Blue) rail of the breadboard. Use the Fritzing breadboard view at the top of this page to help you out.

OK, that was easy. Now we have to build a power supply for the Servo Motor. We need to do this because if you try to power the Servo with the 5V pin from the Arduino UNO board, the motor activity will cause an enormous amount of noise in the system and the Pulse Sensor will act really weird! We are using a standard 7805 5V regulator.

Connect the GND pin to the GND (Blue) rail of your breadboard, and the 5V pin to the POWER (Red) rail of your breadboard. Place the 0.1uF Capacitor between the Regulator Input pin and the GND pin. It's easiest to do this right next to the 7805. Then connect the 100uF Capacitor between the Regulator output pin and GND. It's easiest to place the 100uF Cap right across the power rails. 

Make sure to pay attention to the polarity of the 100uF Capacitor!

Now, it's easy enough to 'jump' from the power rails on the breadboard to make connection to your Servo Motor. The Arduino UNO Servo Motor control pin is digital pin 6. Use a jumper wire to connect digital pin 6 to the breadboard row where the control wire is connected.

Now it's time to upload the code. Launch the Arduino IDE, and then go to:

File > Examples > PulseSensor Playground > PulseSensor_Servo

Make sure you select Arduino UNO as your target board, and the correct Serial Port. Then upload the code and you're off and running! That's basically it! Now you have an LED that will do a fancy fade to you heartbeat, and a Servo Motor that will pulse right along with your pulse! Neato!

The PulseSensor_Servo example by default sends it's data in a format that the Arduino Serial Plotter can render. To visualize your Pulse, BPM, and IBI (Inter-Beat Interval) just click on the 

Tools > Serial Plotter

You should see a graph similar to the one in the video above. We have also made a Pulse Sensor Visualizer in Processing, a creative coding language. To use our Visualizer, first download Processing, and then follow the instructions on the READ_ME HERE to install and run our program. You will also need to make a small change to the Arduino code to get it all to work. Near the top of the PulseSensor_Servo sketch there is a line that reads

const int OUTPUT_TYPE = SERIAL_PLOTTER;

Change this line to

const int OUTPUT_TYPE = PROCESSING_VISUALIZER;

And then reprogram your Arduino UNO with the altered sketch. Here's a video of what that looks like when you run the Pulse Sensor Processing Visualizer.

 

 

Have Fun!