Skip to content

Commit 4d173ab

Browse files
authored
Add RGB control via touch pads
Implement touch controls to adjust RGB values for the LED.
1 parent 055d8e7 commit 4d173ab

File tree

1 file changed

+29
-0
lines changed
  • Gemma/Gemma_LightTouch/red_green_blue

1 file changed

+29
-0
lines changed
Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
# SPDX-FileCopyrightText: 2018 Kattni Rembor for Adafruit Industries
2+
#
3+
# SPDX-License-Identifier: MIT
4+
5+
"""Touch each pad to change red, green, and blue values on the LED"""
6+
import time
7+
8+
import adafruit_dotstar
9+
import board
10+
import touchio
11+
12+
led = adafruit_dotstar.DotStar(board.APA102_SCK, board.APA102_MOSI, 1)
13+
touch_A0 = touchio.TouchIn(board.A0)
14+
touch_A1 = touchio.TouchIn(board.A1)
15+
touch_A2 = touchio.TouchIn(board.A2)
16+
17+
r = g = b = 0
18+
19+
while True:
20+
if touch_A0.value:
21+
r = (r + 1) % 256
22+
if touch_A1.value:
23+
g = (g + 1) % 256
24+
if touch_A2.value:
25+
b = (b + 1) % 256
26+
27+
led[0] = (r, g, b)
28+
print((r, g, b))
29+
time.sleep(0.01)

0 commit comments

Comments
 (0)