After speaking to PhD. Koch about incorporating the blinking of the LEDs I decided to not go with the incorporation of the blinking LEDs. At first I thought this would be settling for something really basic and kind of boring; something that didn’t really demonstrate any kind of special purpose for the arduino.
However, I explained how I felt like I needed more time to get to know how to program the arduino better to successfully incorporate this part. My problem was that I wasn’t able to turn the leds on or off when I incorporated the blinking part.
I think by presenting this basic project well, I’ll be able to build on it, which is something I really want to work on this summer! Furthermore, by reflecting on the process it took me to figure out the switch, I realized that it was not a completely trivial project for me and I actually learned quite a bit.
I followed this video to program the button and learned about debugging and how to incorporate it into the code.
This is the code I ended up using:
nt switchPin=8;// This is the pin the switch is connected to
int ledPina=7;//These are the pins the LEDs are connected to
boolean lastButton=LOW;// Keeps track of the value of the button in the previous loop
boolean ledOn=false;// Keeps track of the current state of the LED
boolean currentButton =LOW;// Keeps track of the current button value(Use it with debounce function)
void setup ()
boolean debounce (boolean last)// Creates a function called debounce with input last
boolean current =digitalRead (switchPin);// Determines the current value of the switch
if (last !=current)//
delay(5);// Gives switch enough time to finish debouncing
current=digitalRead(switchPin);// Here it’s read again, presuming that it’s at a steady value
return current;//This returns the steady value
if (lastButton==LOW && currentButton== HIGH)
ledOn=!ledOn; //inverts the value of LED from what it previously was
lastButton= currentButton;// Gets set to current button
This is the data I took (It can also be seen on figshare ):
|pin #||Input Voltage (LED off)||Input Voltage(LED on)||Output voltage (LED off)||Output voltage( LED on)|