Tutorial

Arduino Uno

Contact us at any time

Door No.510
Samastha jubilee memorial soudham
Mele-thampanoor
Thiruvananthapuram
Kerala-695001
Ph:+91 9633 11 80 80
Email:info@hexcodeplus.com

Enquire and suggestions

Whatsapp +91 9633 11 80 80

Arduino interfac with Switch

Let's study how to interface Push Button Switch using Arduino program. you can study how an inpud device interface with arduino Uno and its connections.connect Switch one leg to arduino Power pin (5v) and connect other switch leg to arduino pin 2 (used for input) and also connect to arduino GND pin with a 10k ohm resistor



for an indication connect LED to arduino pin 13 (LED +ve leg) and ground (LED -ve leg)



Arduino Program

#define button 2
#define LED 13

int x = 0;

void setup()
{
  pinMode(button, INPUT);
  pinMode(LED, OUTPUT);
}

void loop()
{
  x = digitalRead(button);

  if (x == HIGH)
  {
    digitalWrite(LED, HIGH);
  }
  else
  {
    digitalWrite(LED, LOW);
  }
}

open arduino New page and upload this code


Follow us

Tutorials / Code