This valentine’s day, save money on chocolates and flowers and make people fall in love with you with a simple button.
For this project, 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.
In order to fulfill the condition of having more than one input or output, I had 3 different speeds, to replicate the heart beat getting faster (this is how you know the button has made your special someone fall in love with you, their heart beats faster when you are around 😉 ) as well as an on/off option.
I used the blink code, firstly adjusting it to make it blink like a heartbeat (with a short delay and then a longer delay), then using for loop to make all the LEDs do the same action at the same time. I used index, with {0, 200, 100, 30}; as the delays, to make the button increase the speed of and turn on/off the lights.
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); } }