Datasheet

9
try:
# Get X/Y coordinates
x = grovepi.analogRead(xPin)
y = grovepi.analogRead(yPin)
# Calculate X/Y resistance
Rx = (float)(1023 - x) * 10 / x
Ry = (float)(1023 - y) * 10 / y
# Was a click detected on the X axis?
click = 1 if x >= 1020 else 0
print "x =", x, " y =", y, " Rx =", Rx, " Ry =", Ry, " click =",
click
time.sleep(.5)
except IOError:
print "Error"}
5. Run the demo.
sudo python grove_thumb_joystick.py