const int threshold = 127;
const int center = 1023/2;
const uint8_t xPin = A2;
const uint8_t yPin = A1;
void loop() {
int xVal = analogRead (xPin);
int yVal = analogRead (yPin);
if (xVal < (center - threshold)) { // Left
; // left key does nothing in main menu
}
if (xVal > (center + threshold)) { // Right
; // right key does nothing in main menu
}
if (yVal < (center - threshold)) { // Down
mode_select--;
if (mode_select < 1) // wrap around menu
mode_select = numModes;
}
if (yVal > (center + threshold)) { // Up
mode_select++;
if (mode_select > numModes) // wrap around menu
mode_select = 1;
}
}
Pieter