Simple test¶
Ensure your device works with this simple test.
1# SPDX-FileCopyrightText: 2021 ladyada for Adafruit Industries
2# SPDX-License-Identifier: MIT
3"""NeoKey simpletest."""
4import board
5from adafruit_neokey.neokey1x4 import NeoKey1x4
6
7# use default I2C bus
8i2c_bus = board.I2C()
9
10# Create a NeoKey object
11neokey = NeoKey1x4(i2c_bus, addr=0x30)
12
13print("Adafruit NeoKey simple test")
14
15# Check each button, if pressed, light up the matching neopixel!
16while True:
17 if neokey[0]:
18 print("Button A")
19 neokey.pixels[0] = 0xFF0000
20 else:
21 neokey.pixels[0] = 0x0
22
23 if neokey[1]:
24 print("Button B")
25 neokey.pixels[1] = 0xFFFF00
26 else:
27 neokey.pixels[1] = 0x0
28
29 if neokey[2]:
30 print("Button C")
31 neokey.pixels[2] = 0x00FF00
32 else:
33 neokey.pixels[2] = 0x0
34
35 if neokey[3]:
36 print("Button D")
37 neokey.pixels[3] = 0x00FFFF
38 else:
39 neokey.pixels[3] = 0x0