forked from pimoroni/pmk-circuitpython
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathreactive-press.py
32 lines (24 loc) · 875 Bytes
/
reactive-press.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
# SPDX-FileCopyrightText: 2021 Sandy Macdonald
#
# SPDX-License-Identifier: MIT
# This example demonstrates how to light keys when pressed.
# Drop the `pmk` folder
# into your `lib` folder on your `CIRCUITPY` drive.
from pmk import PMK
from pmk.platform.keybow2040 import Keybow2040 as Hardware # for Keybow 2040
# from pmk.platform.rgbkeypadbase import RGBKeypadBase as Hardware # for Pico RGB Keypad Base
# Set up Keybow
keybow = PMK(Hardware())
keys = keybow.keys
# Use cyan as the colour.
rgb = (0, 255, 255)
while True:
# Always remember to call keybow.update() on every iteration of your loop!
keybow.update()
# Loop through the keys and set the LED to cyan if pressed, otherwise turn
# it off (set it to black).
for key in keys:
if key.pressed:
key.set_led(*rgb)
else:
key.set_led(0, 0, 0)