Detect switch on digitalread Posted on June 1, 2012 by ellen const int buttonPin = 3; int buttonState = 0; void setup() { Serial.begin(9600); pinMode(buttonPin, INPUT); } void loop(){ buttonState = digitalRead(buttonPin); Serial.println(buttonState); }
This switch doesn’t work this way, use the info in Fritzing to find that you always need to use the center pin. Reply ↓
This switch doesn’t work this way, use the info in Fritzing to find that you always need to use the center pin.
Thank you MAS3! I have changed the sketch and switch now!