Hi Folks. I have an issue where I’m trying to read some digital pins and their voltages aren’t quite low enough. I’m looking for suggestions.
Here’s the story:
I’ve built a split keyboard so I’ll just describe one of them but both behave the same.
I had left and right hand PCBs manufactured. Each uses an Atmega328. Pins 0 through 4 are outputs and set high. They are my rows. And I’m not using pin 0 to receive anything so I think this should be okay.
I’m using analog pins 0 through 5 as digital inputs with the internal pull up set. These are the columns.
I have an outer loop that sequentially sets each row to low. I have a nested loop that runs through each column then tries a digitalRead on the corresponding pin. If it’s LOW, then I know that the key at the corresponding row and column has been pressed.
Now all of this works great for most of the keys except those furthest from the MCU. When I probe these with an oscilloscope, I can see a nice square wave with the voltage drop to a bit above 3V. The other keys, the ones that work, drop a bit further - just below 3V which is evidently enough to be read as LOW.
If I do an analogRead rather than digitalRead, and check if the value is less than 900, all of the keys work but things become too slow after I add logic to handle modifier keys (shift, ctrl, etc.).
I wonder if the diodes by each key may have too high a resistance - preventing the pins from dropping low fast enough. The diodes are 1N4148s. They are there to prevent ghosting.
I’ve also fiddled with setting the output pins’ bits directly to speed things up (rather than use the digitalWrite) but haven’t figured out how to do a similarly fast read of the analog pins.
Other stuff:
I use a 5V voltage regulator.
16MHz oscillators with a couple of 22uF diodes
A couple of 220uF electrolytic caps between the main rail and ground
The keyboards is use the Bluefruit LE Friend to interface with my computer/iPad.
Given that I already have these PCBs made, introducing an op amp or other complex component may be problematic. What might I try to get this working just right?
FYI, I’ve been learning electronics since around January so please pardon my ignorance. Thanks for your time.