#define LedPin 4 #define SwitchPin 3 void setup() { pinMode(SwitchPin,INPUT); pinMode(LedPin,OUTPUT); } void loop() { boolean switchState; switchState=digitalRead(SwitchPin); if(switchState){ digitalWrite(LedPin,HIGH); } else{ digitalWrite(LedPin,LOW); } }