HOW TO CONTROL AN LED USING ARDUINO BUTTON WITH ARDUINO CODE

Опубликовано: 04 Июнь 2026
на канале: Gideon Buniel
61
1

#Arduino #ArduinoButton #ArduinoLED

in this video, we show you how to control an LED using button. We added the Arduino Code for you to upload to Arduino IDE. Listen to this Arduino tutorial for beginners because we still want to build Arduino projects in the future.

Related searches:
arduino,arduino led,arduino button,arduino led button,led button,control led using button,how to control led using button,arduino led button code,code for arduino led using button, arduino uno, arduino uno r3, arduino uno board

Arduino Code to control led using button:

/**********************************/
const int keyPin = 12; //the number of the key pin
const int ledPin = 13;//the number of the led pin
/**********************************/
void setup()
{
pinMode(keyPin,INPUT);//initialize the key pin as input
pinMode(ledPin,OUTPUT);//initialize the led pin as output
}
/**********************************/
void loop()
{
//read the state of the key value
//and check if the kye is pressed
//if it is,the state is HIGH
if(digitalRead(keyPin) ==HIGH )
{
digitalWrite(ledPin,HIGH);//turn on the led
}
else
{
digitalWrite(ledPin,LOW);//turn off the led
}
}
/************************************/

Join this channel to get access to perks:
   / @gideonbuniel