Page 1 of 1

GPIOs firing every ~3 milliseconds

Posted: Fri Jul 17, 2015 2:43 pm
by dboy1612
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).

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)
});
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!

Re: GPIOs firing every ~3 milliseconds

Posted: Fri Jul 17, 2015 2:48 pm
by PeterO
dboy1612 wrote: I attached the wires from a single button to my 5v pin and GPIO pin 23 (no breadboard or anything at the moment).
Time for a new Pi then.... Next time, read up on GPIO voltage ranges (hint: use the 3V3 pin not the 5V pin).

PeterO

Re: GPIOs firing every ~3 milliseconds

Posted: Fri Jul 17, 2015 2:49 pm
by RST8
This might be of interest:

Pull up resistors

Along with keeping to 3.3V..
Joe

Re: GPIOs firing every ~3 milliseconds

Posted: Fri Jul 17, 2015 3:03 pm
by FTrevorGowen
RST8 wrote:This might be of interest:
Pull up resistors
Along with keeping to 3.3V..
Joe
Personally I would also add a "debounce capacitor"** (rather than, just rely on software "debouncing") across the switch contacts.
Trev.
** Historically, for 5V TTL, that was typically ~10K pull-up and a 0.1uF capacitor - greater capacitance values perhaps being used for "reset circuits" like that shown here:
http://www.cpmspectrepi.webspace.virgin ... dCacc.html