digitalRead() returning false positive

Thread Starter


Joined Nov 27, 2012
I am a hobbyist and just learning to program microcontrollers. My goal with the current project is to create a simple wireless mode controller for some NeoPixels (a turn signal for my bicycle). I want to have a switch on my handlebars to choose between two display modes for the NeoPixels at the back of my bike. For better or worse, I've selected Adafruit's Feather M0 packet radio (RFM69) for the wireless connection.

I have made my own button debounce class (based on debounce code provided for Arduino) and tested the code on an Adafruit Feather Huzzah. When I use essentially the same code on the RFM69, I poll the button state each time through the main loop(). Without touching the button, the chip reports a button press every ~1000 (random) times through the loop.

I don't believe it is a code problem (although I may be wrong) and I suspect it is some sort of electronic noise artifact. I think adding a simple capacitor filter might help, but I'm not sure where to put it to help.

  • Am I barking up the wrong tree?
  • If not, where would I install the capacitor?
  • What else should I consider?