Creating single LED blink program using push button
Required Components
- LED -1 no
- 220 Ω Resistor -1 no
- 10 KΩ Resistor -1 no
- Push button -1 no
- Bread Board -1 no
- Arduino Board -1 no
- Connecting wires -1 Set
Circuit
Steps
- Make sure the components are working properly.
- Connect Arduino board 5v and GND pin to the bread board by using wires.
- Connect 220 Ω Resistor to the LED Anode (+) pin and cathode (-) pin to Gnd.
- Connect 220 Ω Resistor another pin to Arduino pin 9.
- Connect 10 k Ω Resistor to the switch button.
- Connect switch button another pin to the Arduino pin 7.
- When we press the push button LED blinks.
- Check the Arduino program.
- Check the circuit connections.
- Run the Arduino program.
Arduino Program
int ledPin = 9;
int buttonPin = 7;
void setup()
{
pinMode(ledPin, OUTPUT);
pinMode(buttonPin, INPUT);
}
void loop()
{
int button = digitalRead(buttonPin);
if (button==HIGH)
{
digitalWrite(ledPin,HIGH);
}
else
{
digitalWrite(ledPin, LOW);
}
}
Usage
- Switching operations.