Header Ads

Arduino Program for Turn On Led through Push Button

Arduino Program for Turn On Led through Push Button

Arduino Program for Turn On Led through Push Button

Component Required

  • Arduino Uno
  • Breadboard
  • Pushbutton
  • Led
  • jumper wires

Arduino Code

int led = 4;
int switch = 2;

void setup() 
{
  pinMode(led,OUTPUT);
  pinMode(switchh,INPUT);
}

void loop() 
{
  if (digitalRead(switchh) == 0)
    digitalWrite(led,HIGH);
  else
    digitalWrite(led,LOW);
}

Note: This Arduino Code is also can be used for controlling any electrical or electronics components like Relay, Buzzer, Bulb, Fan, etc.

No comments:

Popular Posts

Theme images by 5ugarless. Powered by Blogger.