Ignoring HIGH/LOW values until state change

Hi All,

I am working on a custom HID Keyboard. I wish to code the arduino to recognise a state change of a switch and press a single keystroke at this event as opposed to a continuous stream of keystrokes.

Example: Turn switch "on" a single keystroke "A" is transmitted, as opposed to "AAAAAAAAAAAAAAAAAAAAAAAAAAAA"

I know I could use a spring switch with a debounce but it wouldn't simulate the purpose of this switch.

I haven't been able to find an example of the code which is similiar and I'm not sure where to begin.

I am overthinking this?

Thanks,

if current state is not equal to the state i saved the last time i looked then do something else do nothing.

Mark

Thanks Mark, that should get me out of trouble. :sweat_smile: