How to Read INPUT from SWITCH


How to Read INPUT from SWITCH




How to Read INPUT from SWITCH


COPY AND PAST THE CODE IN ARDUINO IDE SKETCH

------------------------------------------------------------------------------------
                                                     CODE
------------------------------------------------------------------------------------


int switch1=2;
int LED1=13;
int buttonstate=0;

void setup() {
  // put your setup code here, to run once:
pinMode(switch1,INPUT);
pinMode(LED1,OUTPUT);
}

void loop() {
   // put your main code here, to run repeatedly:
  buttonstate=(digitalRead(switch1);

  if (buttonstate==HIGH)
  {
    digitalWrite(LED1,HIGH);
  }

else
  {
    digitalWrite(LED1,LOW);
  }
  // put your main code here, to run repeatedly:
}
----------------------------------------------------------------------------------








1 comment:

Wifi Home automation Diy kit

 Wifi Home automation Diy kit By Manmohan Pal Wifi Home Automation Kit Hi, This is Manmohan Pal, I am glad to present a DIY kit for Home Aut...