code.py
 1  # SPDX-FileCopyrightText: 2021 Kattni Rembor for Adafruit Industries
 2  #
 3  # SPDX-License-Identifier: MIT
 4  
 5  """
 6  Circuit Playground Bluefruit Light-Up Tone Piano
 7  
 8  Touch the each of the touchpads around the outside of the board to play a tone for each pad.
 9  Touch A6 and TX at the same time to play the final tone in the octave. A0 is not a touchpad.
10  """
11  
12  from adafruit_circuitplayground import cp
13  
14  cp.pixels.brightness = 0.3
15  
16  while True:
17      if cp.touch_A1:
18          cp.pixels.fill((255, 0, 0))
19          cp.start_tone(262)
20      elif cp.touch_A2:
21          cp.pixels.fill((210, 45, 0))
22          cp.start_tone(294)
23      elif cp.touch_A3:
24          cp.pixels.fill((155, 155, 0))
25          cp.start_tone(330)
26      elif cp.touch_A4:
27          cp.pixels.fill((0, 255, 0))
28          cp.start_tone(349)
29      elif cp.touch_A5:
30          cp.pixels.fill((0, 255, 255))
31          cp.start_tone(392)
32      elif cp.touch_A6 and not cp.touch_TX:
33          cp.pixels.fill((0, 0, 255))
34          cp.start_tone(440)
35      elif cp.touch_TX and not cp.touch_A6:
36          cp.pixels.fill((100, 0, 255))
37          cp.start_tone(494)
38      elif cp.touch_A6 and cp.touch_TX:
39          cp.pixels.fill((255, 0, 255))
40          cp.start_tone(523)
41      else:
42          cp.pixels.fill((0, 0, 0))
43          cp.stop_tone()