The setup is covered in tutorials like this one: Arduino Joystick Module Example |
The rest is simple C stuff, once you obtain the values with
Code:
xPosition = analogRead(xPin);
yPosition = analogRead(yPin);
This assumes you've setup xPin and yPin (check the tutorial), and have integers xPosition and yPosition.
Once you read these, you choose to do with yPosition as you describe, but what "goto right" means depends on way too much information we don't have....is the Arduino controlling motors or something?
Also, what "press space" means is unclear. I assume something should happen when space is pressed - perhaps what you really need is merely to do that thing, whatever it is, when xPosition is positive.
However, what is important to keep in mind is that positions taken from a joystick happen in a loop, repeated rapidly. That's why "goto right" is unclear. What if the sample of xPosition is at a rate of 100 times per second, do you want to "goto right" 100 times each second?
These things require a plan, and to make that plan we must have far more information about the rest of what you're doing.