Hi Power_Broker,
Thanks for your help. Unfortunately, the result is the same - left and right work fine. I'm unable to test up/down, because they don't function in the main menu. The switch doesn't work, same as before.
Thanks also for looking at the code. To answer your question, the code was originally written (by Mr Liming) to work with the LCD keypad shield, which uses up/down/left/right/select microswitches. These microswitches are all tied to analog pin 0 (A0), to save the digital input pins. Each has a different resistor value allowing the different keypresses to be differentiated, and the code was originally written to reflect that.
I'd prefer to use a single joystick rather than the tiny buttons on the LCD shield. The analog game controller style joysticks are cheap and fit my project box - I didn't come across a digital equivalent at a similar price point.
But, now you highlight it, I'm wondering if this line:
if (analogRead(AnalogKeyPin) < 850 ) // if a keypress is present
is why my "buttonstate == HIGH" isn't functioning as expected? i.e. the switch is wired to digital input 2, so analogkeypin doesn't drop its value and so get_real_key never happens
I tried this instead:
if ((analogRead(AnalogKeyPin) < 850) || (digitalRead(SW_pin) == HIGH)) // if a keypress is present
It compiles fine, but doesn't seem to make a difference.
Lastly, thanks for your suggestions re: code formatting and indenting. 99% of the code isn't mine, but that said it's a lot better formatted than I'd be able to do! I'm by no means a programmer, but I'm trying ![]()
Lee