/* The code for the switch that controls the LED on the LilyPad Arduino is from the website at http://lilypadarduino.org/?page_id=635 The code regarding the delay of the blinking LED is in the public domain and may be found in the Arduino software's examples of codes. The code regarding the delay of the blinking LED was modified May 8, 2014 by Scott Fitzgerald and I modified the code again on March 12, 2015 to cause the LED to have a delay of three seconds and to designate the correct pins. I received tips about connecting the pins from Casey Rawson. */ int ledPin = 13; // LED is connected to digital pin 13 int switchPin = A5; // switch connected to digital pin A5 int switchValue; // a variable to keep track of when switch is pressed void setup() { pinMode(ledPin, OUTPUT); // sets the ledPin to be an output pinMode(switchPin, INPUT); // sets the switchPin to be an input digitalWrite(switchPin, HIGH); // sets the default (unpressed) state of switchPin to HIGH } void loop() // run over and over again { switchValue = digitalRead(switchPin); // check to see if the switch is pressed if (switchValue == LOW) { // if the switch is pressed then, digitalWrite(ledPin, HIGH); // turn the LED on delay(3000); // wait for three seconds digitalWrite(ledPin, LOW); // turn the LED off by making the voltage LOW delay(3000); // wait for three seconds } else { // otherwise, digitalWrite(ledPin, LOW); // turn the LED off } }