Skip to content

Instantly share code, notes, and snippets.

@lesp
Created January 18, 2020 16:32
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save lesp/ce820dff3744c548d21ade2021b26324 to your computer and use it in GitHub Desktop.
Save lesp/ce820dff3744c548d21ade2021b26324 to your computer and use it in GitHub Desktop.
This is the code which is not working as expected, the Y value is wildly wrong.
import smbus
import time
bus = smbus.SMBus(1)
address = 0x48
print("Please ensure that the joystick is centred, the test will start in...")
for i in range(3,0,-1):
print(i)
time.sleep(1)
print("The resting value for each axis is as follows...")
time.sleep(1)
y = bus.read_byte_data(address, 1)
x = bus.read_byte_data(address, 0)
print("Y = ",y,"X = ",x)
print("Move the joystick to the top and hold...")
time.sleep(3)
y = bus.read_byte_data(address, 1)
print(y)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment