fbpx

Interface Switch With Arduino

The switch is a component that connects two points in a circuit when you press it.

LED turns on when you press the button.

Hardware Required

  • Push Button.
  • 220 ohms Resistor
  • Arduino Uno.

Circuit

Code

 int led = 13;
 int button =12;
 void setup()
 {
 pinMode(led, OUTPUT);
 pinMode(button,INPUT);
 }
 void loop()
 {
 if (button == LOW)
 {
 digitalWrite(led, HIGH);    // LED on
 delay(1000);    // wait for a second
 }
 else
 {
 digitalWrite(led, LOW);    // LED off
 delay(1000);    // wait for a second
 }
 }

Leave a Reply

Your email address will not be published. Required fields are marked *