//How to read a switch? (or a digital input pin) void setup() { Serial.begin(115200); pinMode(2,INPUT); // Set PIN 2 to be an INPUT } void loop() { int switchVariable = digitalRead(2); //read the value of pin 2 Serial.println(switchVariable); //print the value to the serial monitor delay(10); //Short delay so that we don't send too much serial data! }