There are seven touch pads around the outside of the Circuit Playground Bluefruit, labeled A1 - A6 and TX. (A0 is not a touch pad!) This example plays a different tone and lights up the NeoPixels a different color for each touch pad touched.

Try touching the pads to hear a tone and see the NeoPixels light up. Touch each pad individually for one of seven different tones, and touch A6 and TX at the same time for the eighth tone.

# SPDX-FileCopyrightText: 2021 Kattni Rembor for Adafruit Industries
# SPDX-License-Identifier: MIT

Circuit Playground Bluefruit Light-Up Tone Piano

Touch the each of the touchpads around the outside of the board to play a tone for each pad.
Touch A6 and TX at the same time to play the final tone in the octave. A0 is not a touchpad.

from adafruit_circuitplayground import cp

cp.pixels.brightness = 0.3

while True:
    if cp.touch_A1:
        cp.pixels.fill((255, 0, 0))
    elif cp.touch_A2:
        cp.pixels.fill((210, 45, 0))
    elif cp.touch_A3:
        cp.pixels.fill((155, 155, 0))
    elif cp.touch_A4:
        cp.pixels.fill((0, 255, 0))
    elif cp.touch_A5:
        cp.pixels.fill((0, 255, 255))
    elif cp.touch_A6 and not cp.touch_TX:
        cp.pixels.fill((0, 0, 255))
    elif cp.touch_TX and not cp.touch_A6:
        cp.pixels.fill((100, 0, 255))
    elif cp.touch_A6 and cp.touch_TX:
        cp.pixels.fill((255, 0, 255))
        cp.pixels.fill((0, 0, 0))

This guide was first published on Nov 17, 2021. It was last updated on Jul 21, 2024.