5 int switchPin = 2; // Switch connected to digital pin 2
7 void setup() // run once, when the sketch starts
9 Serial.begin(9600); // set up Serial library at 9600 bps
10 pinMode(switchPin, INPUT); // sets the digital pin as input to read switch
14 void loop() // run over and over again
16 Serial.print("Read switch input: ");
17 Serial.println(digitalRead(switchPin)); // Read the pin and display the value