Introduction: 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.

Step 1: Materials and Sensor Set-up

Step 2: Circuit Construction and Crafting

Step 3: 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

Step 5: Working CardioCraft!

3rd Epilog Challenge

Participated in the
3rd Epilog Challenge