I am programming an Adafruit Trinket to convert an analog signal from a momentary switch to a spacebar. I am almost there, except whenever I depress the analog button, I get a bunch of spaces. I'd like it to only produce one space with each push, and ideally not produce another until the button is released and depressed again. Here is my code - what am I missing? Thanks so much for anything you can tell me!
I feel you pain. The best thing for you to do is look at a few tutorials on debouncing inputs. Also there is a section on this in the Arduino Cookbook. There are a lot of solutions, pick one or two that you understand.
The other thing to worry about is button bounce... the easiest (not necessarily the best) way to handle that is to put a small delay (say 100ms) when you detect a key press.