Skip to content

Instantly share code, notes, and snippets.

@lesp
Created January 18, 2020 16:28
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/d1823b12ff0478bcca432cfcbe221da1 to your computer and use it in GitHub Desktop.
Save lesp/d1823b12ff0478bcca432cfcbe221da1 to your computer and use it in GitHub Desktop.
This code works! It constantly prints the values reported from an analog to I2C board as I move an analog joystick around.
import smbus
import time
bus = smbus.SMBus(1)
address = 0x48
while True:
y = bus.read_byte_data(address, 1)
x = bus.read_byte_data(address, 0)
print("Y = ",y,"X = ",x)
time.sleep(0.01)
@lesp
Copy link
Author

lesp commented Jan 18, 2020

Output looks like this

Y = 184 X = 219
Y = 184 X = 219
Y = 184 X = 219
Y = 184 X = 219
Y = 184 X = 219
Y = 184 X = 219
Y = 184 X = 219
Y = 184 X = 219
Y = 184 X = 219
Y = 184 X = 219
Y = 184 X = 219

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment