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