loading
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. 

Step 1: 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

Step 2: 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.

Step 3: 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.

Step 4: 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. 

Step 5: 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! 

Step 6: 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;
}
}
}
}
<p>No offense, but it seems that project circuits like these, are completely useless. Seeing as most people DON'T happen to have an Arduino laying around to make something like this, a real circuit diagram would be great. I cannot tell you how many times that I've seen an interesting project title, clicked the link, and found out its just another Arduino or similar based project.</p>
it's not even pointless. this tutorial is helpful for beginners to build up more interesting projects. no offense but I'm pretty sure that you started with this &quot;useless&quot; project when you first began fiddling with arduino
I'm sorry you find this pointless.&nbsp; Perhaps it's because you didn't fully read the instructable.&nbsp; I have a link to video instruction, a breadboard diagram, and a programming tutorial.&nbsp; <br /> <br /> I think your frustration is because it's not clear that most of these arduino tutorials are smaller bits of code used in much larger projects.&nbsp; For me in particular I needed to figure this bit of code out and place it inside a much larger and way cooler project.&nbsp; I'll be sure to post the larger non-useless project once it's completed.&nbsp; <br /> <br /> One last thing - anyone looking for arduino instructables will already have an arduino.&nbsp; You're basically says you're mad because you searched for instructions on how to play World of Warcraft without purchasing the video game itself.&nbsp; <br /> <br /> <br />
<p>agreed these tutorials also help beginners learning how to make their own code and possibly put it into a bigger project. Thanks for the tutorial awesome job .</p>
<p>You might try a while loop. <a href="http://arduino.cc/en/Reference/While" rel="nofollow">http://arduino.cc/en/Reference/While </a> Set the while to true. ex. while (true) </p><p>A word of caution about infinite looping - you can crash a system asking it to run forever. :) </p><p>I don't have my arduino in front of me to test it, sorry. </p>
<p>great tutorial.Just what i was looking for.I do have a question.Can you help me to write the code to make the led blink infinite instead of 10times.Thanks.</p>
No offense, but I don&acute;t understand the reason to use a device so advanced as a Arduino just to blink a led for ten seconds. The same could be done with a couple of 555&acute;s, saving power and using a very smaller circuit board than this Arduino option.

About This Instructable

16,886views

6favorites

License:

More by jesicadawn:Push Button Blinking Light 
Add instructable to: