code.py
 1  # SPDX-FileCopyrightText: 2017 Kattni Rembor for Adafruit Industries
 2  #
 3  # SPDX-License-Identifier: MIT
 4  
 5  from adafruit_circuitplayground import cp
 6  
 7  while True:
 8      if cp.switch:
 9          print("Slide switch off!")
10          cp.pixels.fill((0, 0, 0))
11          cp.stop_tone()
12          continue
13      if cp.touch_A4:
14          print('Touched A4!')
15          cp.pixels.fill((15, 0, 0))
16          cp.start_tone(262)
17      elif cp.touch_A5:
18          print('Touched A5!')
19          cp.pixels.fill((15, 5, 0))
20          cp.start_tone(294)
21      elif cp.touch_A6:
22          print('Touched A6!')
23          cp.pixels.fill((15, 15, 0))
24          cp.start_tone(330)
25      elif cp.touch_A7:
26          print('Touched A7!')
27          cp.pixels.fill((0, 15, 0))
28          cp.start_tone(349)
29      elif cp.touch_A1:
30          print('Touched A1!')
31          cp.pixels.fill((0, 15, 15))
32          cp.start_tone(392)
33      elif cp.touch_A2 and not cp.touch_A3:
34          print('Touched A2!')
35          cp.pixels.fill((0, 0, 15))
36          cp.start_tone(440)
37      elif cp.touch_A3 and not cp.touch_A2:
38          print('Touched A3!')
39          cp.pixels.fill((5, 0, 15))
40          cp.start_tone(494)
41      elif cp.touch_A2 and cp.touch_A3:
42          print('Touched "8"!')
43          cp.pixels.fill((15, 0, 15))
44          cp.start_tone(523)
45      else:
46          cp.pixels.fill((0, 0, 0))
47          cp.stop_tone()