#define led 22
#define switch1 2
void setup() {
// put your setup code here, to run once:
pinMode(led, OUTPUT);
pinMode(switch1, INPUT_PULLUP);
Serial.begin(9600);
}
void loop() {
// put your main code here, to run repeatedly:
int switchState = digitalRead(switch1);
if (switchState == 0)
{
digitalWrite(led, HIGH);
Serial.println("Switch ON, Led ON");
}
else
{
digitalWrite(led, LOW);
Serial.println("Switch Off, Led Off");
}
}