I've build a 4x3 grid of keys from a mechanical keyboard and wired them all up to my Arduino Pro Micro. All the wiring works, I have tested everything using LEDs. The switches are all hooked up to output and input pins, I have not added any resistors or anything else to it. When I turn the arduino on without pressing or powering any of the switches and plot the signals from the input pins I receive square-waves. There should not be any power in those cables and the pins should be reading 0 but what I get is a square-wave.
I think that because of the grid-like layout and large wires I have unintentionally build an antenna that is picking up a signal in the room. What can I do about this? The ghost-signal is not strong enough to show up on the LEDs, will adding resistors work?
I would greatly appreciate any advice.
Schematic? (Not Fritzing crap please). Otherwise we are just guessing what you have connected.
Why are the switches connected to output pins? (SCHEMATIC).
How long are the wires between the Arduino and the switches?
"without powering the powering any of the switches" What???? (SCHEMATIC)
That is likely part, if not most of the problem, leading to floating inputs. Please post a hand drawn schematic diagram of the wiring.
Here's the shematic. Since the Pro Micro only has 12 Digital pins and I wanted to save on cables I have connected all switches in a column. The idea is to only enable one of the 3 power lines at a time allowing to determine exactly which button is pressed.
The longest wire is about 16cm, the average is about 10cm. They are a bit thicker than the usual type since that was what I had on hand.
I suspect that you will find the answer here: Buttons and other electro-mechanical inputs (introduction)
Try pinMode(, INPUT_PULLUP) to make sure the inputs don't float.
Add a pullup resistor to each input, mode INPUT_PULLUP may help. Or pulldown, depending on your wiring and code.
How do you know that? Did you scope it?
I used Arduinos serial monitor. Thank you all for your suggestions, changing the pinMode to INPUT_PULLUP did the trick and I did not have to change any of the circuitry.
That's always a relief.
This topic was automatically closed 180 days after the last reply. New replies are no longer allowed.