Playground Color Picker

You can use your Circuit Playground Bluefruit with the Adafruit Bluefruit LE Connect mobile app to control the NeoPixel RGB LEDs on the CPB!

The Code

Plug your Circuit Playground Bluefruit into your computer, and save the following as code.py on the CIRCUITPY drive:

# CircuitPython NeoPixel Color Picker Example

import board
import neopixel
from adafruit_ble import BLERadio
from adafruit_ble.advertising.standard import ProvideServicesAdvertisement
from adafruit_ble.services.nordic import UARTService
from adafruit_bluefruit_connect.packet import Packet
from adafruit_bluefruit_connect.color_packet import ColorPacket

ble = BLERadio()
uart_service = UARTService()
advertisement = ProvideServicesAdvertisement(uart_service)

pixels = neopixel.NeoPixel(board.NEOPIXEL, 10, brightness=0.1)

while True:
    # Advertise when not connected.
    ble.start_advertising(advertisement)
    while not ble.connected:
        pass
    ble.stop_advertising()

    while ble.connected:
        if uart_service.in_waiting:
            packet = Packet.from_stream(uart_service)
            if isinstance(packet, ColorPacket):
                print(packet.color)
                pixels.fill(packet.color)

Connect to your board through the Adafruit Bluefruit LE Connect mobile app. If you need assistance, check out this page on installing and using the app.

Once connected, from the device menu, tap on Controller, then Color Picker. Choose a color from the dial and tap Select (Android) or Send selected color (iOS). The LEDs will light up in the color you chose!

This guide was first published on Sep 12, 2019. It was last updated on Sep 12, 2019.
This page (Playground Color Picker) was last updated on Aug 09, 2020.