Instructables
Picture of ECG Necktie
project goals
to create a circuit-connected necktie
containing a light up heart which can
blink based on a wearer’s input. The
input can either be based on detecting
a subject’s heart-rate or can be based
on bending a flex sensor.
 
Remove these adsRemove these ads by Signing Up

Step 1: Materials and Sensor Set-up

Picture of Materials and Sensor Set-up

Step 2: Circuit Construction and Crafting

Picture of Circuit Construction and Crafting

Step 3: Arduino Code

Picture of Arduino Code


const int heartSig = A1; // output from ECG circuit
const int beatLight = 9; // 3 ultrabright LEDs in center
const int rimLight = 11; //10 LEDs around edge of heart
const int switchHigh = 5; //high comparator for switch
const int switchLow = 3; //low comparator for switch
const int switchVal = 4; //switch read pin
const int bendVal = A0; // output from flex sensor
const int speakerPin = 10; // positive lead fromspeaker
int bend = 1000; //initialize delay to 1000




void setup() {
  // initialize pins:
  pinMode(bendVal, INPUT); //flex sensor
  pinMode(beatLight, OUTPUT); //center LEDs
  pinMode(rimLight, OUTPUT); // rim LEDs
  pinMode(switchHigh, OUTPUT); //pin HIGH
pinMode(switchLow, OUTPUT); //pin LOW
pinMode(switchVal, INPUT); //switch comparator
pinMode(heartSig, INPUT); //ECG signal
pinMode(speakerPin, OUTPUT); //tone output
digitalWrite(switchHigh, HIGH); //initialize switch comparators
digitalWrite(switchLow, LOW);
Serial.begin(9600);
}


void loop() {
switch(digitalRead(switchVal)) // read the function switch
{
case HIGH: //if the switch is in HIGH mode
tone(speakerPin, 50, 50); //low beat sound
digitalWrite(rimLight, HIGH); //initialize down beat lights
digitalWrite(beatLight, LOW);
delay(bend); //wait one second

bend = analogRead(bendVal); //get flex sensor data
bend = map(bend, 700, 250, 1500,50); //map observed sensor range to delay
tone(speakerPin, 70, 70); // high beat sound
digitalWrite(rimLight, LOW); //initialize up beat lights
digitalWrite(beatLight, HIGH);
delay(bend); //delay again
break;

case LOW: //if switch in low position
digitalWrite(rimLight, LOW); //turn off all lights
digitalWrite(beatLight, LOW);
//would like following line to map the signal from the mean to the max of the signal
int heartMod = map(analogRead(heartSig), 650,700, 0, 1024); //read signal and map
Serial.println(heartMod); //output for setting threshholds above

while(heartMod > 40) { //if the signal is greater than the mean (with error)
digitalWrite(rimLight, HIGH); //set lights on
delay(50);
digitalWrite(beatLight, HIGH);
break;
}
break;
}


}








 

Step 4: Working ECG

Picture of Working ECG

Step 5: Working cardioCraft!

Picture of Working cardioCraft!
xenomorph150 made it!4 months ago

I just made the project, without the flexbar. I think this project requires serious adjustment, especially in the

int heartMod = map(analogRead(heartSig), 650,700, 0, 1024); //read signal and map

while(heartMod > 40) { //if the signal is greater than the mean (with error)

Areas. My Values came from 650 - 800 and I had to adjust the while (heartMod > 600). But I doubt that this was intended by the author. Maybe I did something wrong.

2014-03-10 19.12.04.jpg
xenomorph1504 months ago

Cool project.

Just a question: Is there a way to drive this project directly with 5V or 3.3V? So that you only need one voltage? Would be a lot easier to provide one voltage via one step up / down generator while "on the run" :).

xboxone2 years ago
Hey, thanks so much for sharing this, I'm a complete n00b to Arduino and electronics in general, I think I have most of the circuit figured out but I'm still unsure of what "U1A" and "U3A" stand for, could you please clarify that? Also, I could only find "AD623ANZ" (http://www.newark.com/analog-devices/ad623anz/ic-instrument-amp-800khz-110db/dp/59K4402?Ntt=ad623an) and "LMC6484AIN/NOPB" (http://www.newark.com/national-semiconductor/lmc6484ain-nopb/ic-op-amp-1-5mhz-1-3v-%C2%B5s-dip-14/dp/41K2665), would those be ok? Thanks again!
fortueni3 years ago
Very simple & easy, Thank Your for taking the time =)
it looks great.
I´ll post pictures when I finish it.
zazenergy3 years ago
Great! You may want to check out Heart Spark. It also detects your heart rate but has a custom PCB in the heart. 
zazenergy3 years ago
This looks like an AWESOME project. One problem is that I can't read the Arduino code at all. Can you retype that, or make the picture bigger? This looks like a lot of fun!
iheartqwerty (author)  zazenergy3 years ago
Thanks!

Code now included as text.

Also if you click the 'i' in the upper left corner of any picture you can choose to view it as its original size by clicking 'original' on the left hand side!