Push Button Blinking Light
This instructable explains how to make an LED light blink on and off for ten seconds by pressing the on button. As well, the light can be turned off by pressing a separate off button.
This example is similar to the "Button Pressing Pushbuttons CIRC-07" example provided in the Arduino Experimentation Kit - ARDX.
This example is similar to the "Button Pressing Pushbuttons CIRC-07" example provided in the Arduino Experimentation Kit - ARDX.
Required Parts
Breadboard Sheet
Arduino Duemilanove
2 Push Buttons
2 10K OHM Resistors - Brown - Black - Orange
1 560 OHM Resistor Green - Blue - Brown
1 Red LED
7 wires
Arduino Duemilanove
2 Push Buttons
2 10K OHM Resistors - Brown - Black - Orange
1 560 OHM Resistor Green - Blue - Brown
1 Red LED
7 wires
Receiving 5V Power
Place one side of a connection wire into the Gnd (ground) digital pin on circuit board and the other side into the negative pin on the bottom of the bread board.
Place one side of a connection wire into the 5V digital pin on the circuit board and the other side into the positive pin on the bottom of the bread board.
Place one side of a connection wire into the 5V digital pin on the circuit board and the other side into the positive pin on the bottom of the bread board.
Wiring the LED Light
Place one side of a connection wire into digital pin 13 on the circuit board and the other side into pin J 19 of the bread board.
Place the 560 OHM Resistor (Green - Blue - Brown) into a negative pin in the breadboard (preferably in the same column as 19 or 20) and the other side of the resistor into pin J20 on the breadboard.
Place the LED light into pins H 19 and 20 of the breadboard. NOTE: The longer metal lead of the LED light is the positive side and should go into pin 19.
Place the 560 OHM Resistor (Green - Blue - Brown) into a negative pin in the breadboard (preferably in the same column as 19 or 20) and the other side of the resistor into pin J20 on the breadboard.
Place the LED light into pins H 19 and 20 of the breadboard. NOTE: The longer metal lead of the LED light is the positive side and should go into pin 19.
Wiring the OFF Push Buttons
Place one side of a connection wire into digital pin 3 on the circuit board and the other side into pin H 10 of the bread board.
Place one side of a connection wire into pin I 8 of the breadboard and the other side into a negative pin (preferably in the same column 8) of the bread board.
Place the 10K OHM Resistors (Brown - Black - Orange) into a positive pin in the breadboard (preferably in the same column as 10) and the other side of the resistor into pin I 10 on the breadboard.
Place the 4 pin Push Button into E 8 and 10 and F 8 and 10 of the breadboard.
Place one side of a connection wire into pin I 8 of the breadboard and the other side into a negative pin (preferably in the same column 8) of the bread board.
Place the 10K OHM Resistors (Brown - Black - Orange) into a positive pin in the breadboard (preferably in the same column as 10) and the other side of the resistor into pin I 10 on the breadboard.
Place the 4 pin Push Button into E 8 and 10 and F 8 and 10 of the breadboard.
Wiring the ON Push Buttons
Place one side of a connection wire into digital pin 2 on the circuit board and the other side into pin H 6 of the bread board.
Place one side of a connection wire into pin I 4 of the breadboard and the other side into a negative pin (preferably in the same column 4) of the bread board.
Place the 10K OHM Resistors (Brown - Black - Orange) into a positive pin in the breadboard (preferably in the same column as 4) and the other side of the resistor into pin I 6 on the breadboard.
Place the 4 pin Push Button into E 4 and 6 and F 4 and 6 of the breadboard.
That's all the wiring!
Place one side of a connection wire into pin I 4 of the breadboard and the other side into a negative pin (preferably in the same column 4) of the bread board.
Place the 10K OHM Resistors (Brown - Black - Orange) into a positive pin in the breadboard (preferably in the same column as 4) and the other side of the resistor into pin I 6 on the breadboard.
Place the 4 pin Push Button into E 4 and 6 and F 4 and 6 of the breadboard.
That's all the wiring!
Arduino Code
This is code combined from the Push Button and Blinking Light examples in the Arduino software and then I modified it to only blink ten times and to have the Off Button work at any point in the blinking sequence.
Here's the Breadboard layout sheet: http://tinyurl.com/dzmh8w
Here's an assembly video: http://www.youtube.com/watch?v=4itYI4vngZU
Here's the original tutorials: http://www.arduino.cc/en/Tutorials
/*
* LED attached from pin 13 to ground
* pushbutton attached to pin 2 from +5V
* 10K resistor attached to pin 2 from ground
*/
int ledPin = 13;
int inputPin1 = 3;
int inputPin2 = 2;
int i = 0;
void setup() {
pinMode(ledPin, OUTPUT);
pinMode(inputPin1, INPUT);
pinMode(inputPin2, INPUT);
}
void loop(){
if (digitalRead(inputPin1) == LOW) {
digitalWrite(ledPin, LOW);
}
else if (digitalRead(inputPin2) == LOW) {
digitalWrite(ledPin, HIGH);
for (int i = 0; i < 10; i++) {
digitalWrite(ledPin, HIGH);
delay(1000);
digitalWrite(ledPin, LOW);
delay(1000);
if (digitalRead(inputPin1) == LOW) {
digitalWrite(ledPin, LOW);
break;
}
}
}
}
Here's the Breadboard layout sheet: http://tinyurl.com/dzmh8w
Here's an assembly video: http://www.youtube.com/watch?v=4itYI4vngZU
Here's the original tutorials: http://www.arduino.cc/en/Tutorials
/*
* LED attached from pin 13 to ground
* pushbutton attached to pin 2 from +5V
* 10K resistor attached to pin 2 from ground
*/
int ledPin = 13;
int inputPin1 = 3;
int inputPin2 = 2;
int i = 0;
void setup() {
pinMode(ledPin, OUTPUT);
pinMode(inputPin1, INPUT);
pinMode(inputPin2, INPUT);
}
void loop(){
if (digitalRead(inputPin1) == LOW) {
digitalWrite(ledPin, LOW);
}
else if (digitalRead(inputPin2) == LOW) {
digitalWrite(ledPin, HIGH);
for (int i = 0; i < 10; i++) {
digitalWrite(ledPin, HIGH);
delay(1000);
digitalWrite(ledPin, LOW);
delay(1000);
if (digitalRead(inputPin1) == LOW) {
digitalWrite(ledPin, LOW);
break;
}
}
}
}