Skip to content

Instantly share code, notes, and snippets.

What would you like to do?
i2c bus
import smbus
from gpiozero import Button
import time
class joystick:
def __init__(self, button_pin):
self.i2cbus = smbus.SMBus(1)
self.button = Button(button_pin)
def getXPos(self):
self.x = self.i2cbus.read_byte_data(0x48,0x01)
return self.x
#sudo apt-get install build-essential python-dev python-smbus
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment