Simple test

Ensure your device works with this simple test.

examples/nunchuk_simpletest.py
 1# SPDX-FileCopyrightText: 2021 ladyada for Adafruit Industries
 2# SPDX-License-Identifier: MIT
 3
 4import time
 5import board
 6import adafruit_nunchuk
 7
 8nc = adafruit_nunchuk.Nunchuk(board.I2C())
 9
10while True:
11    x, y = nc.joystick
12    ax, ay, az = nc.acceleration
13    print("joystick = {},{}".format(x, y))
14    print("accceleration ax={}, ay={}, az={}".format(ax, ay, az))
15
16    if nc.buttons.C:
17        print("button C")
18    if nc.buttons.Z:
19        print("button Z")
20    time.sleep(0.5)