heart beat monitor – love story part 2

This week’s prompt was to have something unexpected in our project, to have an element of surprise. But since we were specifically asked for a surprise, anything we make will not be a surprise, as it would be expected! This was such a dilemma for me. Therefore I decided to tweak and change the use of my previous project, since my audience already knew how it worked, to create an unexpected surprise.

Valentine’s day is over. Now, even though my project might look the same, it is no longer a tool showing a person’s love to you, but has transformed into a heart rate monitor. The heart beats go faster and faster with pressing the button, but when a hand is held over the light sensor, the heart stops beating and creates the beeping sound of a heart rate monitor when a heart stops. Many love stories, such as Romeo and Juliet, end with death, this is one of them.

For this project (like love story part 1), I used 10 LED lights, and put them into a piece of poster board in the shape of  heart. I used different circuits for each LED as well as the button. At first I tried to solder the LEDs to the wires before poking them into the surface, but then found that this made the LEDs not stand up straight and move around due to the large hole. Therefore I decided to solder the LEDs after having put them into the board. I soldered the power and ground side of each LED separately, therefore using a total of 20 wires for the soldering. I considered having the button on the board too but decided that I want it to be eventually framed and still be able to use the button, so it would be better to have it separate. In order to make them fixed on the board, I glue gunned the LEDs from the back on to the board.

For this project I adjusted the code, and wiring, in order to add a light sensor and buzzer and have the light sensor turn off the lights and turn on the buzzer.

int ledPin1 = 3;
int ledPin2 = 6;
int buttonPin = 2;
int index = 0;
int prevButtonState = LOW;
int lowDelay[4] = {0, 200, 100, 30};
unsigned long toggleTime = 0;
int triggerInterval = 500;
int buzz = 13;

//  Blink

//  Turns an LED on for one second, then off for one second, repeatedly.
//
//  Most Arduinos have an on-board LED you can control. On the UNO, MEGA and ZERO
//  it is attached to digital pin 13, on MKR1000 on pin 6. LED_BUILTIN is set to
//  the correct LED pin independent of which board is used.
//  If you want to know what pin the on-board LED is connected to on your Arduino
//  model, check the Technical Specs of your board at:
//  https://www.arduino.cc/en/Main/Products
//
//  modified 8 May 2014
//  by Scott Fitzgerald
//  modified 2 Sep 2016
//  by Arturo Guadalupi
//  modified 8 Sep 2016
//  by Colby Newman
//
//  This example code is in the public domain.
//
//  http://www.arduino.cc/en/Tutorial/Blink
//*/

// the setup function runs once when you press reset or power the board
void setup() {
  // initialize digital pin LED_BUILTIN as an output.
  for (int i=3; i<=12;i++){
    pinMode(i,OUTPUT);
  }
  pinMode (buttonPin, INPUT);
  Serial.begin(9600);
}

// the loop function runs over and over again forever
void loop() {
  int currentButtonState = digitalRead(buttonPin);
  int knobValue = analogRead(A0);
  Serial.println(knobValue);

if (knobValue <50) { 
  index = 0;
  }
  
  if (currentButtonState == HIGH && prevButtonState == LOW) {
    index = index + 1;
    if(index >= 4){
      index = 0;
    }
//    Serial.println(index);
  }

  if(index != 0){
    for (int i = 3;i<=12;i=i+1){
      digitalWrite(i, HIGH);
    }
    
    delay(100);
  
    for (int i = 3;i<=12;i+=1){
      digitalWrite(i, LOW);
    }
    
    delay(lowDelay[index]);
    
    for (int i = 3;i<=12;i++){
      digitalWrite(i, HIGH);
    }
    
    delay(100);
  
    for (int i = 3;i<=12;i++){
      digitalWrite(i, HIGH);
    }
    
    delay(1000);
  
    for (int i = 3;i<=12;i++){
      digitalWrite(i, LOW);
    }
    
    delay(lowDelay[index]);
    
    for (int i = 3;i<=12;i++){
      digitalWrite(i, HIGH);
    }
    
    delay(100);
    
    for (int i = 3;i<=12;i++){
      digitalWrite(i, HIGH);
    }
  } else {
    for (int i = 3;i<=12;i++){
      digitalWrite(i, LOW);
    }
  }
  prevButtonState = currentButtonState;
  
//    for (int i = 3;i<=12;i++){
//     if (knobValue == 0)
//       { 
//        digitalWrite(i,LOW);
//       }
//    }

    int LIGHT = analogRead(13);
    if (LIGHT < 100){
      tone(buzz, 3000, 50);
    }

}

 

Leave a Reply