Attach Big Red Button to GPIO - Raspberry Pi Forums


i picked 4 of these adafruit;
https://www.adafruit.com/products/473

@ moment i'd connect 1 directly gpio on rpi b (no breadboard). how go doing correctly? have button wired , trying access using node , https://github.com/fivdi/onoff , using latest rasbian.

i'm new messing gpios, @ moment have 1 end on 3.3v , other on gpio 4. code dead simple, not receiving anything. doing wrong? thanks!

code: select all

var gpio = require('onoff').gpio; var button = new gpio(4, 'in', 'both');  console.log('starting watch button'); button.watch(function (err, value) {   if (err) {     console.log('error: ' + error)   }   console.log('button pressed!'); });

i don't know enough software comment on code, i'd add reasonably high value resistor (say 10k) between gpio pin , 0v looks like:
3.3v ....switch....gpio....resistor....0v
makes sure gpio pin stays low when switch isn't pressed.


raspberrypi



Comments

Popular posts from this blog

Authentication error while password reset - Raspberry Pi Forums

opencv3, tbb and rasp pi 2 - Raspberry Pi Forums

small ethernet problem - Raspberry Pi Forums