Skip to content

Instantly share code, notes, and snippets.

@rayterrill
Created April 27, 2016 04:21
Show Gist options
  • Save rayterrill/ee70e434a27014089c60f5297ef701c2 to your computer and use it in GitHub Desktop.
Save rayterrill/ee70e434a27014089c60f5297ef701c2 to your computer and use it in GitHub Desktop.
How to read a SPST button with an Arduino
#check out http://fritzing.org/projects/read-spst-arduino for wiring info
const int buttonPin = 5;
int buttonState = 0;
void setup() {
Serial.begin(115200);
//initialize button pin
pinMode (buttonPin, INPUT_PULLUP);
Serial.println("Device starting...");
}
void loop() {
buttonState = digitalRead(buttonPin);
Serial.println(buttonState);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment