Arduino Tutorial #14 using push button to turn on LED light.
Scroll down for code.....
Please like & Subscribe for more videos
If you want to support my video please buy any product through my amazon affiliate link. I will receive a commission, at no extra cost to you.
LIST OF COMPONENT (affiliate links)
[ Ссылка ] (Arduino)
[ Ссылка ] (Pushbutton)
[ Ссылка ] (Breadboard)
[ Ссылка ] (Resistor)
[ Ссылка ] (Jumper wire)
[ Ссылка ] (LED)
const int buttonPin = 2;
const int led_Red = 13;
const int led_Green = 8;
int buttonState = 0;
void setup() {
pinMode(buttonPin, INPUT);
pinMode(led_Red , OUTPUT);
pinMode(led_Green, OUTPUT);
}
void loop() {
buttonState = digitalRead(buttonPin);
if (buttonState == HIGH) {
digitalWrite(led_Green, HIGH);
digitalWrite(led_Red , LOW);
} else {
digitalWrite(led_Red , HIGH);
digitalWrite(led_Green, LOW);
}
}
Ещё видео!