Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save miketrebilcock/be16bc2b77b88a401d5faaf89ed055ac to your computer and use it in GitHub Desktop.
Save miketrebilcock/be16bc2b77b88a401d5faaf89ed055ac to your computer and use it in GitHub Desktop.
i2c bus
import smbus
from gpiozero import Button
import time
class joystick:
def __init__(self, button_pin):
self.i2cbus = smbus.SMBus(1)
self.i2cbus.write_byte(0x48,0)
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