import adafruit_lis3dh import board import busio import time import adafruit_hid.mouse import usb_hid rat = adafruit_hid.mouse.Mouse(usb_hid.devices) i2c = busio.I2C(board.ACCELEROMETER_SCL, board.ACCELEROMETER_SDA) lis3dh = adafruit_lis3dh.LIS3DH_I2C(i2c, address=25) lis3dh.range = adafruit_lis3dh.RANGE_2_G umbral1 = 2 umbral2 = 1 while True: x, y, z = lis3dh.acceleration if x > umbral1 and y < umbral2 and y > -umbral2: rat.move(-10, 0) if x < -umbral1 and y < umbral2 and y > -umbral2: rat.move(10, 0) if y > umbral1 and x < umbral2 and x > -umbral2: rat.move(0, 10) if y < -umbral1 and x < umbral2 and x > -umbral2: rat.move(0, -10) time.sleep(0.1)