Attach Big Red Button to GPIO
Posted: Thu Jul 09, 2015 3:25 pm
I recently picked up four of these from Adafruit;
https://www.adafruit.com/products/473
At the moment I'd like to connect just one directly to the GPIO on my RPi B (no breadboard). How would I go about doing this correctly? I have the button wired up and am trying to access using Node and https://github.com/fivdi/onoff and using the latest Rasbian.
I'm fairly new to messing with the GPIOs, at the moment I have one end on 3.3v and the other on GPIO 4. Code is dead simple, but am not receiving anything. What am I doing wrong? Thanks!
https://www.adafruit.com/products/473
At the moment I'd like to connect just one directly to the GPIO on my RPi B (no breadboard). How would I go about doing this correctly? I have the button wired up and am trying to access using Node and https://github.com/fivdi/onoff and using the latest Rasbian.
I'm fairly new to messing with the GPIOs, at the moment I have one end on 3.3v and the other on GPIO 4. Code is dead simple, but am not receiving anything. What am I doing wrong? Thanks!
Code: Select all
var Gpio = require('onoff').Gpio;
var button = new Gpio(4, 'in', 'both');
console.log('Starting Watch for Button');
button.watch(function (err, value) {
if (err) {
console.log('ERROR: ' + error)
}
console.log('BUTTON PRESSED!');
});