Test Code:
Code: Select all
# SPDX-FileCopyrightText: 2021 ladyada for Adafruit Industries
# SPDX-License-Identifier: MIT
"""NeoKey simpletest."""
import board
from adafruit_neokey.neokey1x4 import NeoKey1x4
# use default I2C bus
i2c_bus = board.I2C()
# Create a NeoKey object
neokey = NeoKey1x4(i2c_bus, addr=0x30)
print("Adafruit NeoKey simple test")
# Check each button, if pressed, light up the matching neopixel!
while True:
if neokey[0]:
print("Button A")
neokey.pixels[3] = 0xFF0000
else:
neokey.pixels[0] = 0x0
if neokey[1]:
print("Button B")
neokey.pixels[2] = 0xFFFF00
else:
neokey.pixels[1] = 0x0
if neokey[2]:
print("Button C")
neokey.pixels[2] = 0x00FF00
else:
neokey.pixels[2] = 0x0
if neokey[3]:
print("Button D")
neokey.pixels[3] = 0x00FFFF
else:
neokey.pixels[3] = 0x0
Code: Select all
# SPDX-FileCopyrightText: 2021 ladyada for Adafruit Industries
# SPDX-License-Identifier: MIT
"""NeoKey simpletest."""
import board
from adafruit_neokey.neokey1x4 import NeoKey1x4
import time
# use default I2C bus
i2c_bus = board.I2C()
# Create a NeoKey object
neokey = NeoKey1x4(i2c_bus, addr=0x30)
print("Adafruit NeoKey simple test")
x = 0
while x < 4:
neokey.pixels[x] = 0xFF0000
time.sleep(2)
x+=1
neokey.pixels[0]=0x0
neokey.pixels[1]=0x0
neokey.pixels[2]=0x0
neokey.pixels[3]=0x0
Let me know if there is any more information needed.
Thanks!