Arduino Beginner Project #3: How to Build Simple Torchlight using Arduino Uno
Arduino Beginner Project #3: How to Build Simple Torchlight using Arduino Uno
About Project:
The LED will light up when push button is pressed.
Components:
- Arduino Uno
- Breadboard
- LED
- Push button
- Resistor 220 Ohm
- Resistor 10k Ohm
- Jumper Male-to-male
- USB cable
Schematic Diagram:
Coding using Arduino IDE:
#define LED 11
#define BUTTON 2
int button_state;
void setup() {
pinMode(LED,OUTPUT);
pinMode(BUTTON,INPUT);
}
void loop() {
button_state = digitalRead(BUTTON);
if (button_state == LOW)
{
digitalWrite(LED,HIGH);
}
else
{
digitalWrite(LED,LOW);
}
}
Watch this project tutorial on Youtube:
Thank you.
Comments
Post a Comment