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:
}
----------------------------------------------------------------------------------
Can you give me full code of the Arduino
ReplyDelete