# Read the various information coming from the trackball # # See GitHub: https://github.com/mchobby/esp8266-upy/tree/master/trackball from machine import I2C from trackball import Trackball import time i2c = I2C(2) # Y9=scl, Y10=sda or Pyboard-Uno-R3 (I2C over pin 13) # initialize the trackball trackball = Trackball(i2c) trackball.set_rgbw(255, 0, 0, 0) while True: up, down, left, right, switch, state = trackball.read() print("r: {:02d} u: {:02d} d: {:02d} l: {:02d} switch: {:03d} state: {}". format(right, up, down, left, switch, state)) time.sleep(0.200)