/ examples / circuitplayground_touch_pixel_rainbow.py
circuitplayground_touch_pixel_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 the nearest
 3  NeoPixel to that pad a different color of the rainbow!"""
 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[6] = (255, 0, 0)
13      if cpx.touch_A2:
14          print("Touched A2!")
15          cpx.pixels[8] = (210, 45, 0)
16      if cpx.touch_A3:
17          print("Touched A3!")
18          cpx.pixels[9] = (155, 100, 0)
19      if cpx.touch_A4:
20          print("Touched A4!")
21          cpx.pixels[0] = (0, 255, 0)
22      if cpx.touch_A5:
23          print("Touched A5!")
24          cpx.pixels[1] = (0, 135, 125)
25      if cpx.touch_A6:
26          print("Touched A6!")
27          cpx.pixels[3] = (0, 0, 255)
28      if cpx.touch_A7:
29          print("Touched A7!")
30          cpx.pixels[4] = (100, 0, 155)
31      time.sleep(0.1)