- Get link
- X
- Other Apps
- Get link
- X
- Other Apps
Simple Pushbutton on off Project 1
Arduino Uno - 01
Breadboard - 01
220 Ohm Resistors - 02
LED - 01
Push Button Switch - 01
Jumper wires
Arduino Sketch
int button = 2; // pin where we connect the button
int LED = 3; // pin where we connect the LED
int buttonState = 0; // Pushbutton State
void setup(){
pinMode (LED,OUTPUT);
pinMode (button,INPUT);
}
void loop(){
buttonState = digitalRead(button); // Pushbutton value state read
if(buttonState == HIGH){ // button press
digitalWrite(LED,HIGH); // LED ON
delay(5000); //LED on for 5 second
}
else{
digitalWrite(LED,LOW); //*if pushbutton not press LED OFF
}
}
Comments
Post a Comment