Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
An Arduino sketch for @Palleas' Big Red Button
/* BigRedButton.ino Arduino Sketch
*
* Notes for @Palleas:
* One post of the Big Red Button should be connected to a digital
* pin, in this case pin 8, of the Arduino.
* The other post of the Big Red Button should be connected to one
* of the Arduino's GND pins.
*
* WARNING: Crosstalk or a weird power glitch _could_ send a false signal.
* It's probably a good idea to have the monitoring service on the computer
* require something like a 5-second button press to confirm any destructive
* actions.
*
* Here's a good candidate for a Big Red Button:
* http://www.digikey.ca/product-detail/en/GPB556A05BR/CW158-ND/2349753
*/
// Select the pin that we connect one side of the Big Red Button to.
static const int pin = 8
void setup() {
Serial.begin(9600); // Start the Serial port at 9600 baud.
pinMode(8, INPUT_PULLUP); // Set the pin to an input and tie it to +5V.
}
void loop() {
// When the button is pressed, it closes the connection between the digital
// pin and the GND pin, pulling the value of the pin from +5V (logic-1) to
// 0V (logic-0).
if (pin == 0) {
// OMG! BUTTON PRESS DETECTED!
// Send a unique string over the Serial port.
Serial.println("OH NOES BALEET ALL THE THINGS 0xDEADBEEF YAY!!1!");
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment