/ examples / circuitplayground_touch_pixel_fill_rainbow.py
circuitplayground_touch_pixel_fill_rainbow.py
 1  """This example uses the capacitive touch pads on the CPX. They are located around the outer edge
 2  of the board and are labeled A1-A7. (A0 is not a touch pad.) This example lights up all the
 3  NeoPixels a different color of the rainbow for each pad touched!"""
 4  import time
 5  from adafruit_circuitplayground.express import cpx
 6  
 7  cpx.pixels.brightness = 0.3
 8  
 9  while True:
10      if cpx.touch_A1:
11          print("Touched A1!")
12          cpx.pixels.fill((255, 0, 0))
13      if cpx.touch_A2:
14          print("Touched A2!")
15          cpx.pixels.fill((210, 45, 0))
16      if cpx.touch_A3:
17          print("Touched A3!")
18          cpx.pixels.fill((155, 100, 0))
19      if cpx.touch_A4:
20          print("Touched A4!")
21          cpx.pixels.fill((0, 255, 0))
22      if cpx.touch_A5:
23          print("Touched A5!")
24          cpx.pixels.fill((0, 135, 125))
25      if cpx.touch_A6:
26          print("Touched A6!")
27          cpx.pixels.fill((0, 0, 255))
28      if cpx.touch_A7:
29          print("Touched A7!")
30          cpx.pixels.fill((100, 0, 155))
31      time.sleep(0.1)