nunchuk_simpletest.py
1 import time 2 import board 3 import adafruit_nunchuk 4 5 nc = adafruit_nunchuk.Nunchuk(board.I2C()) 6 7 while True: 8 x, y = nc.joystick 9 ax, ay, az = nc.acceleration 10 print("joystick = {},{}".format(x, y)) 11 print("accceleration ax={}, ay={}, az={}".format(ax, ay, az)) 12 if nc.button_C: 13 print("button C") 14 if nc.button_Z: 15 print("button Z") 16 time.sleep(0.5)