#include #include #include /* Allow us to see when the switch (pin 21) is on and off */ /* The switch is located below the push buttons (towards the center) */ /* and you can see a + and - associated with it. */ /* Led pin #13 will be on when switch is in on position (+) */ #define SWITCH_PIN 21 /* Switch is associated with pin 21 */ #define LED_PIN 13 void setup(void) { init_serial_stdio(); pinMode(SWITCH_PIN, INPUT); pinMode(LED_PIN, OUTPUT); } void loop(void) { int value_read = digitalRead(SWITCH_PIN); if (value_read == HIGH) { digitalWrite(LED_PIN, HIGH); printf("Switch is on\n"); } else { printf("Switch is off\n"); digitalWrite(LED_PIN, LOW); } delay(100); }