Main Menu

Secondary Menu

NeoPixel LED Heart Sensor Jacket

Start out trying to look like Iron Man, end up thinking a bit about your humanity, have a lot of fun in the process. This project is meant to produce and interesting and unexpected effect from a source that we take for granted, our heart. On a base level this is an Arduino powered jacket that turns your heartbeat into a pulsing ring of light.

Origins

In the beginning I mostly wanted to create something wearable that resembled the arc reactor used by Iron Man, but to add a twist with an unusual input. The heart sensor was the second in a list that ranged from temperature, to sound, and many more.

Material List

- Arduino Uno - Compact microcontroller produced by Arduino, it will allow us to interpret the signals sent by the sensor information here

- Zip Front Hoodie - Cheap or not really depends on what you want aesthetically, but be aware that you will be cutting holes in it, sewing things on to it and generally being rough on the garment

- Pulse Sensor - The sensor I used is specifically made by the guys at pulsesensor.com. The package they send includes the sensor, the velcro strip and discs, sensor covers and a couple other pieces. Their website also includes their custom Arduino library and code that you will need later on.

- (20) Jumper Wires - Make sure you have both male to male, and male to female cables, as both are necessary Information here

- Adafruit 16 Neo Pixel Ring - This ring utilizes 16 individually programmable NeoPixel LED lights, and is available from a Adafruit specifically, but can be found on Amazon for a higher price information here

- Sewing Needle and Thread - Thread that matches the color of your chosen hoodie would be best

- (2) Single LED's - Very cheap single LED's are needed for testing sensors and Arduino output before actual construction begins. Information here

- Soldering Iron and solder - A very small amount of soldering is necessary in this project

Step 1: Pulse Sensor Preparation and Testing

Once you have all your materials put together the first step is to test all our major components.

The pulse sensor is the first, to go to the "Getting Started" tutorial on pulsesensor.com Click here

The link has a basic tutorial in how to prepare the sensor, including casing wires with glue and connections to the arduino itself. The sensor has 3 wires, power (red) , ground (black) and an output (purple) that connect to the 5V, GND, and A0 pins respectively on the Analog side of the Arduino Uno. If your Arduino is plugged in, then the sensor itself should light up bright green.

Be sure to double check your connection before plugging the Arduino in to make sure it doesn't damage the sensor! Its unlikely but possible!

Now that we are sure the sensor works, time to test the code. Navigate back to the tutorial linked above and click on the GitHub image to download the PulseSensor libraries for Arduino. Follow the tutorial for instructions on how to install the libraries correctly based on your computers operating system.

Once you have it installed and the Arduino IDE running, open the

PulseSensorAmped_Arduino_1dot2.ino sketch. Verify and Upload this sketch to your arduino and don your pulse sensor and watch for the L light to start blinking along with your heart beat. You can also connect an single LED between pin 13 and the GND pin on the digital side, which should begin blinking along with your pulse.

If these pieces are working as described above, Congrats! Your pulse sensor is working properly, and your first piece of code is uploaded and ready to go!

Step 2: NeoPixel Testing and Preperation

Now that the pulse sensor is working, its time to test your NeoPixel ring as well. This section will be a bit shorter and simpler.

First things first, head over to this site and download the Adafruit NeoPixel libraries for your Arduino Click Here

Download, and unzip as you did with the previous libraries. After that, rename the folder to 'Adafruit_NeoPixel' before dropping it into libraries. If you do not you will have trouble with verifying and uploading your code!

Now, open your Arduino IDE and open the simple sketch from the examples folder in the NeoPixel library.

Disconnect everything from your Arduino if you haven't already, then verify and upload the simple sketch.

Now with the code out of the way, take three of your male to male jumpers and connect two of them to the 5V and GND pins on the Analog side of the arduino. Connect the 3rd one to pin 6 on the digital side. Now connect the 5V jumper to the Power 5V DC hole on the NeoPixel ring. Do the same with GND to Power Signal Ground, and Data Input to pin 6, at this point your ring should light up bright green! If you reset your arduino, the ring will light up one LED at a time bright green.

It may flicker and change color sometimes, but that is only because of the unstable connection between the jumper ends and the contact point on the ring. At this point we are just testing to make sure the ring works.

If you see bright green Pixels, Congrats! Its time to move on to the good stuff!

Step 3: Coding Time!

Alright, now its time to prepare our code. We need to incorporate parts of both of our sketches so that the Arduino will process the input from the heartbeat sensor as well as controlling the NeoPixel ring.

The pulse sensor code will be our base and we will add code from the "simple" sketch we used for the arduino. We need to cut the major portions of the simple sketch out and paste them in their respective places inside the pulse senor code. See Below

// NeoPixel Ring simple sketch (c) 2013 Shae Erisson// released under the GPLv3 license to match the rest of the AdaFruit NeoPixel library
#include <Adafruit_NeoPixel.h>
#ifdef __AVR__
#include <avr/power.h>
#endif
// Which pin on the Arduino is connected to the NeoPixels?
// On a Trinket or Gemma we suggest changing this to 1
#define PIN 6
// How many NeoPixels are attached to the Arduino?
#define NUMPIXELS 16
// When we setup the NeoPixel library, we tell it how many pixels, and which pin to use to send signals.
// Note that for older NeoPixel strips you might need to change the third parameter--see the strandtest
// example for more information on possible values.
Adafruit_NeoPixel pixels = Adafruit_NeoPixel(NUMPIXELS, PIN, NEO_GRB + NEO_KHZ800);
int delayval = 500; // delay for half a second
void setup() {
// This is for Trinket 5V 16MHz, you can remove these three lines if you are not using a Trinket
#if defined (__AVR_ATtiny85__)
if (F_CPU == 16000000) clock_prescale_set(clock_div_1);
#endif
// End of trinket special code
pixels.begin(); // This initializes the NeoPixel library.
}void loop() {
// For a set of NeoPixels the first NeoPixel is 0, second is 1, all the way up to the count of pixels minus one.
for(int i=0;i<NUMPIXELS;i++}{
// pixels.Color takes RGB values, from 0,0,0 up to 255,255,255
pixels.setPixelColor(i, pixels.Color(0,150,0)); // Moderately bright green color.pixels.show(); // This sends the updated pixel color to the hardware.
delay(delayval); // Delay for a period of time (in milliseconds)
}
}

What we need to do is cut out each of the individual parts of this code, specifically the variable declarations on top, as well as the void setup, and void loop portions. Open both this and the Pulse Sensor sketch in seperate windows and transfer each piece of the code from the "simple" sketch over to its respective place in the pulse sensor sketch.

When you are finished it should look like this:

/* Pulse Sensor Amped 1.4 by Joel Murphy and Yury Gitman http://www.pulsesensor.com
---------------------- Notes ---------------------- ----------------------
This code:
1) Blinks an LED to User's Live Heartbeat PIN 13
2) Fades an LED to User's Live HeartBeat
3) Determines BPM
4) Prints All of the Above to SerialRead Me:
https://github.com/WorldFamousElectronics/PulseSe...
---------------------- ---------------------- ----------------------
*
/ Variables
int pulsePin = 0; // Pulse Sensor purple wire connected to analog pin 0
int blinkPin = 13; // pin to blink led at each beat
int fadePin = 5; // pin to do fancy classy fading blink at each beat
int fadeRate = 0; // used to fade LED on with PWM on fadePin
// Volatile Variables, used in the interrupt service routine!
volatile int BPM; // int that holds raw Analog in 0. updated every 2mS
volatile int Signal; // holds the incoming raw data
volatile int IBI = 600; // int that holds the time interval between beats! Must be seeded!
volatile boolean Pulse = false; // "True" when User's live heartbeat is detected. "False" when not a "live beat".
volatile boolean QS = false; // becomes true when Arduoino finds a beat.
// Regards Serial OutPut -- Set This Up to your needs
static boolean serialVisual = true; // Set to 'false' by Default. Re-set to 'true' to see Arduino Serial Monitor ASCII Visual Pulse
//----------------------------- ADAFRUIT VARIABLES-----------------------------
#include <Adafruit_NeoPixel.h>
#ifdef __AVR__
#include <avr/power.h>
#endif
// Which pin on the Arduino is connected to the NeoPixels?
// On a Trinket or Gemma we suggest changing this to 1
#define PIN 8
// How many NeoPixels are attached to the Arduino?
#define NUMPIXELS 16
// When we setup the NeoPixel library, we tell it how many pixels, and which pin to use to send signals.
// Note that for older NeoPixel strips you might need to change the third parameter--see the strandtest
// example for more information on possible values.
Adafruit_NeoPixel pixels = Adafruit_NeoPixel(NUMPIXELS, PIN, NEO_GRB + NEO_KHZ800);
int delayval = 500; // delay for half a second
//--------------------------------------------------------------------------
void setup(){
pinMode(blinkPin,OUTPUT); // pin that will blink to your heartbeat!
pinMode(fadePin,OUTPUT); // pin that will fade to your heartbeat!
Serial.begin(115200); // we agree to talk fast!
interruptSetup(); // sets up to read Pulse Sensor signal every 2mS
// IF YOU ARE POWERING The Pulse Sensor AT VOLTAGE LESS THAN THE BOARD VOLTAGE,
// UN-COMMENT THE NEXT LINE AND APPLY THAT VOLTAGE TO THE A-REF PIN
// analogReference(EXTERNAL);
//------------------------- ADAFRUIT setup code---------------------------
// This is for Trinket 5V 16MHz, you can remove these three lines if you are not using a Trinket
#if defined (__AVR_ATtiny85__)
if (F_CPU == 16000000) clock_prescale_set(clock_div_1);
#endif
// End of trinket special code.
pixels.begin(); // This initializes the NeoPixel library.
}
//--------------------------------------------------------------------------
// Where the Magic Happens
void loop(){
serialOutput() ;
if (QS == true){ // A Heartbeat Was Found
// BPM and IBI have been Determined
// Quantified Self "QS" true when arduino finds a heartbeat
fadeRate = 255; // Makes the LED Fade Effect Happen
// Set 'fadeRate' Variable to 255 to fade LED with pulse
serialOutputWhenBeatHappens(); // A Beat Happened, Output that to serial.
QS = false; // reset the Quantified Self flag for next time
}
ledFadeToBeat(); // Makes the LED Fade Effect Happen
delay(20); // take a break
//------------------------- ADAFRUIT loop code--------------------------------
// For a set of NeoPixels the first NeoPixel is 0, second is 1, all the way up to the count of pixels minus one.
for(int i=0;i<NUMPIXELS;i++){
// pixels.Color takes RGB values, from 0,0,0 up to 255,255,255
pixels.setPixelColor(i, pixels.Color(0,0,255)); // Moderately bright green color.
pixels.show(); // This sends the updated pixel color to the hardware.
delay(2); // Delay for a period of time (in milliseconds).
}
//---------------------------------------------------------------------------
}
void ledFadeToBeat(){
fadeRate -= 15; // set LED fade value
fadeRate = constrain(fadeRate,0,255); // keep LED fade value from going into negative numbers!
analogWrite(fadePin,fadeRate); // fade LED
}

I sectioned out each part of the code as they are spliced together, and I changed a couple values as well, one setting the color of the neopixels in this line:

"pixels.setPixelColor(i, pixels.Color(0,0,255));"

that 255 creates the brightest pure blue they can do, but you can set them to any color you want with RGB values. I also changed the data output pin to 8, Just in case you decide to use my code and things dont seem to be working.

Once you have your code put together verify, as long as you have your brackets in the proper place, it should compile nicely and be ready to go!

Step 4: Electronics Construction

Now that we have our code ready to go, its time to build the actual jacket portion starting with our Arduino connections. Remove all jumpers and wire connections from the arduino, and unplug it.

1. Reconnect the Pulse Sensor in the same way you did earlier when we tested it.

2. Connect a male/male jumper to a male/female jumper to create a double length jumper with male tips on both ends. Now do this two more times so we have a double length jumper for each connection that the NeoPixel ring needs.

3. Now we need to solder one end of each of the three jumpers to the Power 5V DC, Power Signal Ground, and Data Input connections on your NeoPixel ring, and clip off the ends of the jumpers. solder them from the underside of the ring.

4. Now that we have your ring with soldered connections, connect the Power Signal Ground wire to the second GND port on the Analog side, the Data Input wire to the output wire specified in the code, (pin 8 in my version) and finally the Power 5V DC to either pin 13, which will make the ring blink on and off, or to pin 5 which will cause the ring to light up and fade.

Normally the power wire would be connected to a 5 or 3.3V pin on the Arduino, but when it is connected to the output pins that would normally control the single LED's from the original Pulse Sensor sketch, they control the power flow to the NeoPixel ring, lighting it up the same way.

5. Next plug in the 9V battery connector and you should be ready to test!

Step 5: Jacket Construction

This is the last major portion of assembly, is connecting all the major portions of the project to the jacket itself. For this portion all you need is needle and thread, and patience.

1. Sew the pulse sensor to the inside of the right sleeve to keep the wires stable and keep the sensor close to your finger that you want to connect it to. A few tight loops of thread around the wire bundle will do to keep it in place. Also sew another loop around the wires close to the armpit on the inside of the jacket.

2. Sew the arduino to the right side of the jacket on the inside, there are 4 large holes in the board that are perfect to secure it to the jacket with thread

3. Sew the NeoPixel ring to the inside of the jacket, you may have to put it on to get the placement of the ring to the right height, and again use the extra holes that already exist in the ring to sew it on.

4. Sew down the wires as you see fit to make it more comfortable, at this point you should be wearing it and testing as you go.

5. Finally, cut a hole in the back of the front right pocket and feed your battery connector head through it so you can connect the battery on the inside of the pocket without having to unzip and open the jacket.

After you have it secured as much as makes you comfortable, you are ready to go!

Step 6: Wear and Enjoy!

Congrats! You have finished the project!

Plug in your 9 Volt, slip on the pulse sensor strap and enjoy!

Thank you so much for your interest in my project, and if you have any comments or questions please feel free to post them below. Have a great day!