/* Program 2-9 Reading SW2 and use it to control the LED. */ const int LED2 = 5; /* LED2 externally connected*/ const int SW2 = 3; /* SW2 externally connected*/ void setup() { /* configure input output pins for switch and LED */ pinMode(LED2, OUTPUT); pinMode(SW2, INPUT); } void loop() { /* read switch and use the value to set LED */ digitalWrite(LED2, !digitalRead(SW2)); }