Setup Circuit Playground Bluefruit with CircuitPython
We'll need to get our board setup so we can run CircuitPython code. Let's walk through these steps to get the latest version of CircuitPython onto your board.
Mu Python Editor
Mu is a simple Python editor that works with Adafruit CircuitPython hardware. It's written in Python and works on Windows, MacOS, Linux and Raspberry Pi. The serial console is built right in so you get immediate feedback from your board's serial output!
Quick Start
- Download the CircuitPython UF2 for Circuit Playground Bluefruit
- Connect Circuit Playground Bluefruit to your computer over USB and press the Reset button
- Open INFO_UF2.TXT, if the bootloader version is less than 0.6.1 then update the bootloader per this guide page.
- Drag-n-drop the CircuitPython UF2 onto the CPLAYBOOT drive - the drive will vanish and a new CIRCUITPY drive should appear.
- Copy code and library files to the CIRCUITPY drive
Download Adafruit CircuitPython Library Bundle
In order to run the code, we'll need to download a library. The download linked below will contain all the libraries available for CircuitPython. To run the code for this project, we only need the Adafruit Circuit Playground and Adafruit Bluefruit Connect libraries. Unzip the library bundle and search for the library. Drag and drop it onto a folder named lib on the CIRCUITPY drive (create the folder if it is not already on the Circuit Playground Express).
Required Libraries
- adafruit_ble
- adafruit_bluefruit_connect
- neopixel.mpy
Upload Code
Click on the download link below to grab the main code directly from GitHub. Rename the file to code.py and drop it onto the CIRCUITPY main (root) directory. The code will run properly when all of the files have been uploaded.
Use any text editor or favorite IDE to modify the code. We suggest using the Mu Python Editor. See below for more on Mu.
# SPDX-FileCopyrightText: 2019 Dan Halbert for Adafruit Industries # # SPDX-License-Identifier: MIT # 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 while ble.connected: packet = Packet.from_stream(uart_service) if isinstance(packet, ColorPacket): print(packet.color) pixels.fill(packet.color)
Text editor powered by tinymce.