I am trying to use a joystick for controlling something, but the only way I can control it is by having a direction to a corner instead of a side. For example, I would read up when the joystick points to the top left corner. I do that with an if x is greater than 500 (the midpoint) and if the y is greater than 500. Is there a way to make it read when it goes to a side instead of a corner?
if(analogRead(0) < 500 && analogRead(1) < 500){
y--;
} else if (analogRead(0) > 500 && analogRead(1) < 500){
x++;
} else if (analogRead(0) < 500 && analogRead(1) > 500){
x--;
} else if(analogRead(0)>500 && analogRead(1)>500){
y++;
}
I also do know that this is very badly written code, but this code is only for trying to read from a side rather than a corner.