GPIOs firing every ~3 milliseconds
Posted: Fri Jul 17, 2015 2:43 pm
I'm currently building a project using adafruits arcade buttons (https://www.adafruit.com/products/473), and seem to be having a bit of an electrical problem.
Using a Raspberry Pi 2 , and after confirming that wires aren't touching in places they're not supposed to be, I attached the wires from a single button to my 5v pin and GPIO pin 23 (no breadboard or anything at the moment). I plug my RPi's power in to my laptop without a charger plugged in and run the following javascript code (Nodejs 0.12.7).
Everything works exactly as predicted! When I push the button, it's console logged once with value 1 then 0. However now the problem, if I plug it in to my USB power adapter on my power bar, the button starts firing every 1 to 3 milliseconds without touching it, logging value 0. It also rarely accepts when I push the button at all, guessing because the event is being spammed.
To add to the issue, if I plug the Raspberry Pi in to my laptop again, but then an HDMI TV, the same issue happens.
What is it I'm doing wrong here? I'm new to messing with electrical. Do I need a breadboard with a couple other of little things to prevent this from happening when plugged in to the wall? Any help is appreciated. Thanks!
Using a Raspberry Pi 2 , and after confirming that wires aren't touching in places they're not supposed to be, I attached the wires from a single button to my 5v pin and GPIO pin 23 (no breadboard or anything at the moment). I plug my RPi's power in to my laptop without a charger plugged in and run the following javascript code (Nodejs 0.12.7).
Code: Select all
var Gpio = require('onoff').Gpio;
var moment = require('moment');
var firstButton = new Gpio(23, 'in', 'both', {debounceTimeout: 250});
firstButton.watch(function (err, value) {
console.log(moment() + ' Button Pressed | ' + value)
});To add to the issue, if I plug the Raspberry Pi in to my laptop again, but then an HDMI TV, the same issue happens.
What is it I'm doing wrong here? I'm new to messing with electrical. Do I need a breadboard with a couple other of little things to prevent this from happening when plugged in to the wall? Any help is appreciated. Thanks!