# MagicLight Bulb Color Mixer with Circuit Playground Bluefruit

## Overview

https://www.youtube.com/watch?v=qEhtbHLAYho

RGB Bluetooth LE light bulbs (a.k.a. "smart bulbs") for household light sockets are really neat-o, allowing you to create custom lighting effects for your room. Typically, these are controlled with a mobile device app, but we think it's much more fun to build our own custom remote, and use physical sliders to mix colors!

Using **CircuitPython** ,&nbsp;running on the nRF52840-based **Circuit Playground Bluefruit (CPB)**, makes it all possible. We can send the same commands over Bluetooth LE (BLE) from the CPB as you would normally from your mobile device, the proprietary MagicLight app, and a whole lot more!

We'll harness the Circuit Playground Bluefruit board's buttons, slide switch, on-board NeoPixels, and speaker to act as RGB color value indicators, connection state UI, two-position dimmer switch, and momentary light blinkers!

## Parts
**[MagicLight Bluetooth LE Bulb](https://www.magiclightbulbs.com/collections/bluetooth-bulbs/products/bluetooth-smart-bulb-40w)**

You can find these at many online retailers and big box hardware stores.

![leds_Main_Image_Item_569611168_BT_Mini_1024x1024.jpg](https://cdn-learn.adafruit.com/assets/assets/000/086/669/medium640/leds_Main_Image_Item_569611168_BT_Mini_1024x1024.jpg?1578343487)

Featured
### Circuit Playground Bluefruit - Bluetooth® Low Energy

[Circuit Playground Bluefruit - Bluetooth® Low Energy](https://www.adafruit.com/product/4333)
 **Circuit Playground Bluefruit** is our third board in the Circuit Playground series, another step towards a perfect introduction to electronics and programming. We've taken the popular Circuit Playground Express and made it even better! Now the main chip is an nRF52840...

Out of Stock
[Buy Now](https://www.adafruit.com/product/4333)
[Related Guides to the Product](https://learn.adafruit.com/products/4333/guides)
![shot of a Black woman's neon-green manicured hand holding up a Circuit Playground Bluefruit glowing rainbow LEDs.](https://cdn-shop.adafruit.com/640x480/4333-11.jpg)

Featured
### Slide Potentiometer with Plastic Knob - 35mm Long - 10KΩ

[Slide Potentiometer with Plastic Knob - 35mm Long - 10KΩ](https://www.adafruit.com/product/4271)
_Slip slidin' away&nbsp;  
Slip slidin' away&nbsp;  
You know the nearer your resistance&nbsp;  
The more you're slip slidin' away_

If you're tired of the regular-old-twisty potentiometers we carry, why not _slide_ over and try this slide pot?...

In Stock
[Buy Now](https://www.adafruit.com/product/4271)
[Related Guides to the Product](https://learn.adafruit.com/products/4271/guides)
![hand slowly sliding potentiometer back and forth - 35mm Long.](https://cdn-shop.adafruit.com/product-videos/640x480/4271-04.jpg)

Featured
### Half Sized Premium Breadboard - 400 Tie Points

[Half Sized Premium Breadboard - 400 Tie Points](https://www.adafruit.com/product/64)
This is a cute, half-size breadboard with&nbsp;400 tie points, good for small projects. It's 3.25" x 2.2" / 8.3cm&nbsp;x 5.5cm&nbsp;with a standard double-strip in the middle and two power rails on both sides.&nbsp;You can pull the power rails off easily to make the breadboard as...

In Stock
[Buy Now](https://www.adafruit.com/product/64)
[Related Guides to the Product](https://learn.adafruit.com/products/64/guides)
![Angled shot of half-size solderless breadboard with red and black power lines.](https://cdn-shop.adafruit.com/640x480/64-06.jpg)

Featured
### Small Alligator Clip to Male Jumper Wire Bundle - 12 Pieces

[Small Alligator Clip to Male Jumper Wire Bundle - 12 Pieces](https://www.adafruit.com/product/3255)
For bread-boarding with unusual non-header-friendly surfaces, these cables will be your best friends! No longer will you have long strands of alligator clips that are grabbing little wires. These compact jumper cables have a premium male header on one end, and a grippy mini alligator clip on...

In Stock
[Buy Now](https://www.adafruit.com/product/3255)
[Related Guides to the Product](https://learn.adafruit.com/products/3255/guides)
![ Bundle of Small Alligator Clip to Male Jumper Wires](https://cdn-shop.adafruit.com/640x480/3255-02.jpg)

Featured
### Breadboarding wire bundle

[Breadboarding wire bundle](https://www.adafruit.com/product/153)
75 flexible stranded core wires with stiff ends molded on in red, orange, yellow, green, blue, brown, black and white. These are a major improvement over the "box of bent wires" that are sometimes sold with breadboards, and faster than stripping your own solid core wires. Makes...

In Stock
[Buy Now](https://www.adafruit.com/product/153)
[Related Guides to the Product](https://learn.adafruit.com/products/153/guides)
![Bundle of multi-colored multi-length wire jumpers](https://cdn-shop.adafruit.com/640x480/153-04.jpg)

Featured
### Fully Reversible Pink/Purple USB A to micro B Cable - 1m long

[Fully Reversible Pink/Purple USB A to micro B Cable - 1m long](https://www.adafruit.com/product/4111)
This cable is not only super-fashionable, with a woven pink and purple Blinka-like pattern, it's also fully reversible! That's right, you will save _seconds_ a day by not having to flip the cable around.

First let's talk about the cover and over-molding. We got these...

In Stock
[Buy Now](https://www.adafruit.com/product/4111)
[Related Guides to the Product](https://learn.adafruit.com/products/4111/guides)
![Fully Reversible Pink/Purple USB A to micro B Cable](https://cdn-shop.adafruit.com/640x480/4111-02.jpg)

Let's get on with the magic!

![](https://cdn-learn.adafruit.com/assets/assets/000/086/840/medium800thumb/leds_ms-1qCmtr.jpg?1578682495)

# MagicLight Bulb Color Mixer with Circuit Playground Bluefruit

## Understanding BLE 

![](https://cdn-learn.adafruit.com/assets/assets/000/086/706/medium800/leds_512px-BluetoothLogo.svg.png?1578443885)

## BLE Basics

To understand how we communicate between the MagicLight Bulb and the Circuit Playground Bluefruit (CPB), it's first important to get an overview of how Bluetooth Low Energy (BLE) works in general.

The nRF52840 chip on the CPB uses Bluetooth Low Energy, or BLE. BLE is a wireless communication protocol used by many devices, including mobile devices. You can communicate between your CPB and peripherals such as the Magic Light, mobile devices, and even other CPB boards!

There are a few terms and concepts commonly used in BLE with which you may want to familiarize yourself. This will help you understand what your code is doing when you're using CircuitPython and BLE.

Two major concepts to know about are the two modes of BLE devices:

- Broadcasting mode (also called **GAP** for **G** eneric **A** ccess **P** rofile)
- Connected device mode (also called **GATT** for **G** eneric **ATT** ribute Profile).

**GAP** mode deals with broadcasting peripheral advertisements, such as "_I'm a device named LEDBlue-19592CBC_", as well as advertising information necessary to establish a dedicated device connection if desired. The peripheral may also be advertising available services.

**GATT** mode deals with communications and attribute transfer between two devices once they are connected, such as between a heart monitor and a phone, or between your CPB and the Magic Light.

![](https://cdn-learn.adafruit.com/assets/assets/000/086/833/medium800/leds_ble_modes.jpg?1578680670)

## Bluetooth LE Terms

### GAP Mode

#### Device Roles:

- **Peripheral** - The low-power device that broadcasts advertisements. Examples of peripherals include: heart rate monitor, smart watch, fitness tracker, iBeacon, and the Magic Light. The CPB can also work as a peripheral.
- **Central** - The host "computer" that observes advertisements being broadcast by the Peripherals. This is often a mobile device such as a phone, tablet, desktop or laptop, but the CPB can also act as a central (which it will in this project).

#### Terms:

- **Advertising** - Information sent by the peripheral before a dedicated connection has been established. **All** nearby Centrals can observe these advertisements. When a peripheral device advertises, it may be transmitting the name of the device, describing its capabilities, and/or some other piece of data. Central can look for advertising peripherals to connect to, and use that information to determine each peripheral's capabilities (or Services offered, more on that below).

### GATT Mode

#### Device Roles:

- **Server -** In connected mode, a device may take on a new role as a **Server** , providing a Service available to clients. It can now send and receive data packets as requested by the Client device to which it now has a connection.
- **Client -** In connected mode, a device may also take on a new role as **Client** that can send requests to one or more of a Server's available Services to send and receive data packets.

Primary: 

#### Terms:

- **Profile -** A pre-defined collection of **Services** that a BLE device can provide. For example, the Heart Rate Profile, or the Cycling Sensor (bike computer) Profile. These Profiles are defined by the Bluetooth Special Interest Group (SIG). For devices that don't fit into one of the pre-defined Profiles, the manufacturer creates their own Profile. For example, there is not a "Smart Bulb" profile, so the Magic Light manufacturer has created their own unique one.
- **Service** - A function the Server provides. For example, a heart rate monitor armband may have separate Services for **Device Information** , **Battery Service** , and **Heart Rate** itself. Each Service is comprised of collections&nbsp;of information called **Characteristics**. In the case of the Heart Rate Service, the two Characteristics are **Heart Rate Measurement** and **Body Sensor Location.** &nbsp;The peripheral advertises its services.&nbsp;
- **Characteristic -** A Characteristic is a container for the value, or attribute, of a piece of data along with any associated metadata, such as a human-readable name. A characteristic may be readable, writable, or both. For example, the Heart Rate Measurement Characteristic can be served up to the Client device and will report the heart rate measurement as a number, as well as the unit string "bpm" for beats-per-minute. The Magic Light Server has a Characteristic for the RGB value of the bulb which can be written to by the Central to change the color. Characteristics each have a Universal Unique Identifier (UUID) which is a 16-bit or 128-bit ID.
- **Packet** - Data transmitted by a device. BLE devices and host computers transmit and receive data in small bursts called packets.

[This guide](https://learn.adafruit.com/introduction-to-bluetooth-low-energy/introduction) is another good introduction to the concepts of BLE, including GAP, GATT, Profiles, Services, and Characteristics.

# MagicLight Bulb Color Mixer with Circuit Playground Bluefruit

## Reading and Writing Data to BLE Characteristics

## How to Read and Write Data to Characteristics

A good way to get familiar with BLE is to read and write to individual Characteristics using the **Nordic nRF Connect** app for [Android](https://play.google.com/store/apps/details?id=no.nordicsemi.android.mcp&hl=en_US) and [iOS](https://apps.apple.com/us/app/nrf-connect/id1054362403).&nbsp;

Info: 

![](https://cdn-learn.adafruit.com/assets/assets/000/086/819/medium800/leds_android_magic2.jpg?1578673314)

## nRF Connect

First, download and install **nRF Connect** on your mobile device (you cannot use the PC/Mac app without a special Nordic dongle).

Launch the app and you'll see a list of BLE peripheral devices that are broadcasting their advertisements.

Screw the bulb into a standard lamp socket and turn it on.

Find the&nbsp; **LEDBlue** device and click on the&nbsp; **Connect&nbsp;** button. (In case it doesn't show up at first, press the&nbsp; **Scan&nbsp;** button to refresh the list.)

The app will first show the Advertisement Data screen, indicating signal strength of the Magic Light. Swipe left to go to the&nbsp; **Services&nbsp;** page.

Unfortunately, there isn't much helpful info here about what these three Services are, so we'll need to dig deeper into the Characteristics to fine what we need.

Through some poking around in the Android version of the app we discovered that the Service with UUID of FFE5 is the one that contains the Characteristics for RGB color we want.

By pressing the down arrow Read icons for each Characteristic we can request Attributes from the Magic Bulb. Now we see that the Characteristic with UUID FFE6 has an associated User Description Characteristic with the Attribute of "Red"!

By pressing the up arrow "Write" icon next to the FFE6 Characteristic we can open the Write Value dialog box to send an attribute value byte array. In this case we can send anything from 00 to FF in hex (this is 0-255 levels). Type in `FF` for full blast red, then press the **WRITE** button (on Android it is labeled SEND).

![leds_nrf_0222.jpg](https://cdn-learn.adafruit.com/assets/assets/000/086/731/medium640/leds_nrf_0222.jpg?1578514283)

![leds_nrf_0223.jpg](https://cdn-learn.adafruit.com/assets/assets/000/086/734/medium640/leds_nrf_0223.jpg?1578514391)

![leds_nrf_0225.jpg](https://cdn-learn.adafruit.com/assets/assets/000/086/735/medium640/leds_nrf_0225.jpg?1578514422)

![leds_nrf_0229.jpg](https://cdn-learn.adafruit.com/assets/assets/000/086/740/medium640/leds_nrf_0229.jpg?1578515136)

![leds_nrf_0226.jpg](https://cdn-learn.adafruit.com/assets/assets/000/086/743/medium640/leds_nrf_0226.jpg?1578516691)

![leds_nrf_0227.jpg](https://cdn-learn.adafruit.com/assets/assets/000/086/744/medium640/leds_nrf_0227.jpg?1578516910)

![leds_nrf_0228.jpg](https://cdn-learn.adafruit.com/assets/assets/000/086/745/medium640/leds_nrf_0228.jpg?1578516946)

![leds_android_magic2.jpg](https://cdn-learn.adafruit.com/assets/assets/000/086/818/medium640/leds_android_magic2.jpg?1578673271)

## How the MagicLight RGB Color Characteristic Works

The MagicLight Service has a characteristic each for Red, Green, Blue, and White, which we explored above, as well as a combined characteristic for RGBW (although the White element does not seem to be enabled in this characteristic for some reason).

In order to write to the RGB combined attribute, use the UUID FFE9. The byte array looks like this:

`56 FF FF FF 00 F0 AA `

The critical components here are the second, third, and fourth bytes, which are red, green, and blue. The range is `00-FF` (or `0-255` in decimal) so that byte array command would tell the bulb to go full blast red, green, and blue.

![](https://cdn-learn.adafruit.com/assets/assets/000/086/817/medium800/leds_bulb_byte_array.jpg?1578672455)

Next, we'll set up the Circuit Playground Bluefruit with CircuitPython, libraries, and code so we can use it as a Central and a Client to work with the Magic Light bulb.

![](https://cdn-learn.adafruit.com/assets/assets/000/086/849/medium800/leds_ble_modes_cpb.jpg?1578687103)

# MagicLight Bulb Color Mixer with Circuit Playground Bluefruit

## CircuitPython on Circuit Playground Bluefruit

# Install or Update CircuitPython

Follow this quick step-by-step to install or update CircuitPython on your Circuit Playground Bluefruit.

[Download the latest version of CircuitPython for this board via circuitpython.org](https://circuitpython.org/board/circuitplayground_bluefruit/)
 **Click the link above and download the latest UF2 file**

Download and save it to your Desktop (or wherever is handy)

![adafruit_products_CPB_Download_UF2.png](https://cdn-learn.adafruit.com/assets/assets/000/080/530/medium640/adafruit_products_CPB_Download_UF2.png?1567715178)

Plug your Circuit Playground Bluefruit into your computer using a known-good data-capable USB cable.

**A lot of people end up using charge-only USB cables and it is very frustrating! So make sure you have a USB cable you know is good for data sync.**

Double-click the small **Reset** button in the middle of the CPB (indicated by the red arrow in the image). The ten NeoPixel LEDs will all turn red, and then will all turn green. If they turn all red and stay red, check the USB cable, try another USB port, etc. The little red LED next to the USB connector will pulse red - this is ok!

If double-clicking doesn't work the first time, try again. Sometimes it can take a few tries to get the rhythm right!

(If double-clicking doesn't do it, try a single-click!)

![adafruit_products_CPB_Front_Reset_Button_Arrow.jpg](https://cdn-learn.adafruit.com/assets/assets/000/080/532/medium640/adafruit_products_CPB_Front_Reset_Button_Arrow.jpg?1567715535)

You will see a new disk drive appear called **CPLAYBTBOOT**.

&nbsp;

&nbsp;

&nbsp;

Drag the **adafruit\_circuitpython\_etc.uf2** file to **CPLAYBTBOOT.**

![adafruit_products_CPB_CPLAYBTBOOT.png](https://cdn-learn.adafruit.com/assets/assets/000/080/533/medium640/adafruit_products_CPB_CPLAYBTBOOT.png?1567715858)

![adafruit_products_CBP_drag_UF2.png](https://cdn-learn.adafruit.com/assets/assets/000/080/534/medium640/adafruit_products_CBP_drag_UF2.png?1567715871)

The LEDs will turn red. Then, the **CPLAYBTBOOT** drive will disappear and a new disk drive called **CIRCUITPY** will appear.

That's it, you're done! :)

![adafruit_products_CBP_CIRCUITPY.png](https://cdn-learn.adafruit.com/assets/assets/000/080/535/medium640/adafruit_products_CBP_CIRCUITPY.png?1567716034)

# MagicLight Bulb Color Mixer with Circuit Playground Bluefruit

## Code the Color Remote with CircuitPython

## Installing Project Code

To use with CircuitPython, you need to first install a few libraries, into the lib folder on your **CIRCUITPY** drive. Then you need to update **code.py** with the example script.

Thankfully, we can do this in one go. In the example below, click the **Download Project Bundle** button below to download the necessary libraries and the **code.py** file in a zip file. Extract the contents of the zip file, open the directory **CPB\_Magic\_Light\_Mixer/** and then click on the directory that matches the version of CircuitPython you're using and copy the contents of that directory to your **CIRCUITPY** drive.

Your **CIRCUITPY** drive should now look similar to the following image:

![CIRCUITPY](https://adafruit.github.io/Adafruit_Learning_System_Guides/CPB_Magic_Light_Mixer.png )

https://github.com/adafruit/Adafruit_Learning_System_Guides/blob/main/CPB_Magic_Light_Mixer/code.py

## How it Works

### Libraries

First, the code imports the libraries necessary for using Bluetooth LE (`adafruit_ble`, `_bleio`) and the more specialized `adafruit_ble_magic_light` library to deal with the specifics of this profile.

We also import` adafruit_ble.advertising.standard ProvideServicesAdvertisement` so we can do some filtering of the Peripheral advertisements being broadcast by myriad devices and hone in on the ones we want.

Additionally, we import `board`, `analogio AnalogIn`, and `adafruit_circuitplayground` so we can use the sliders, buttons, slide switch, on-board NeoPixels, and speaker on the CPB with simple, high level commands.

```python
import adafruit_ble
from adafruit_ble.advertising.standard import ProvideServicesAdvertisement
from adafruit_ble_magic_light import MagicLightService
import _bleio
import board
from analogio import AnalogIn
from adafruit_circuitplayground import cp
```

### Find Connection

Next we'll define a function called `find_connection()` that we'll use later to search through available Peripheral connections for only the one that offers the `MagicLightService`.

```python
def find_connection():
    for connection in radio.connections:
        if MagicLightService not in connection:  # Filter services
            continue
        return connection, connection[MagicLightService]
    return None, None
```

### Instantiate Radio

We instantiate the Bluefruit LE radio with this command:

`radio = adafruit_ble.BLERadio()`

### Analog Read Setup

To use the slide potentiometers we'll need to define a function called `scale(value)` that can convert the raw analog voltage readings to a 0-255 range that's used per RGB color value.

We'll also define the analog pin read variables for the CPB's A4, A5, and A6 pads.

```python
def scale(value):
    # Scale a value from 0-65535 (AnalogIn range) to 0-255 (RGB range)
    return int(value / 65535 * 255)
a4 = AnalogIn(board.A4)  # red slider
a5 = AnalogIn(board.A5)  # green slider
a6 = AnalogIn(board.A6)  # blue slider
```

Next, we'll set the on-board NeoPixel brightness using the `cp.pixels.brightness = 0.1` command.

We'll also create a variable called `dimmer` and set it to a value of `1.0` -- this will be used as a multiplier for the color values and will be changed to `0.5` when the slide switch is engaged.

## Main Loop

During the main loop of the program, we check to see if there's an active connection, and if not we set the first CPB NeoPixel to yellow.

We then begin scanning through the filtered advertisements for the `MagicLightService` that's being broadcast by the bulb.

If the bulb is found, a connection is made and the CPB's first pixel is set to blue, and a happy tone is played, and the radio stops scanning for connections.

```python
while True:
    if not active_connection:  # There's no connection, so let's scan for one
        cp.pixels[0] = (60, 40, 0)  # set CPB NeoPixel 0 to yellow while searching
        print("Scanning for Magic Light...")
        # Scan and filter for advertisements with ProvideServicesAdvertiesment type
        for advertisement in radio.start_scan(ProvideServicesAdvertisement):
            # Filter further for advertisements with MagicLightService
            if MagicLightService in advertisement.services:
                active_connection = radio.connect(advertisement)
                print("Connected to Magic Light")
                cp.pixels[0] = (0, 0, 255)  # Set NeoPixel 0 to blue when connected
                # Play a happy tone
                cp.play_tone(440, 0.1)
                cp.play_tone(880, 0.1)
                print("Adjust slide potentiometers to mix RGB colors")
                try:
                    bulb = active_connection[MagicLightService]
                except _bleio.ConnectionError:
                    print("disconnected")
                    continue
                break
        radio.stop_scan()  # Now that we're connected, stop scanning
```

### Connected

Once the connection has been made, we check the CPB slide switch to set half or full brightness, and also flip the on board `red_led` on or off respectively to indicate dim/full mode.

We check for the CPB A button press and set the `dimmer` value to 0.0 if pressed.

The `r, g, b`&nbsp;variables are adjusted according to the scaled analog readings of the slide potentiometers, and multiplied by the `dimmer` variable value.

We check for the CPB B button press and set the `r, g, b` values to `255, 255, 255` if pressed.

Now, we create a `color` variable and cast the current `r, g, b` values to it, so we can send these values to the bulb.

```python
while active_connection.connected:  # Connected, now we can set attrs to change colors
        # Toggle slide switch to go to half or full brightness
        if cp.switch:
            cp.red_led = True
            dimmer = 0.5
        else:
            cp.red_led = False
            dimmer = 1.0
 
        # Press the 'A' button to momentarily black the bulb
        if cp.button_a:
            dimmer = 0.0
 
        r = scale(a4.value * dimmer)
        g = scale(a5.value * dimmer)
        b = scale(a6.value * dimmer)
 
        # Press the 'B' button to momentarily white the bulb
        if cp.button_b:
            r, g, b = (255, 255, 255)
 
        color = (r, g, b)
 
        try:
            bulb[0] = color  # Send color to bulb's color characteristic
        except _bleio.ConnectionError:
            print("disconnected")
            continue
```

## Feedback

Since we've got spare pixels on the CPB, why not use them for some user feedback?! We'll set pixels 2, 3, and 4 to the pure red, green, and blue levels and then set pixel 7 to the combined color value, the same as the bulb.

```python
cp.pixels[2] = (r, 0, 0)
cp.pixels[3] = (0, g, 0)
cp.pixels[4] = (0, 0, b)
cp.pixels[7] = (color)
```

Next we'll assemble the parts to use our color mixer!

# MagicLight Bulb Color Mixer with Circuit Playground Bluefruit

## Build the Color Remote

![](https://cdn-learn.adafruit.com/assets/assets/000/086/839/medium800/leds_Screen_Shot_2020-01-10_at_10.34.44_AM.png?1578681431)

I love using slide potentiometers (a.k.a. faders) for this type of project, because at a glance you can tell how much of each color is selected. One problem that can arise, however, when using slide pots, is that they don't usually fit easily on a breadboard or perma proto board. These adorable little 35mm faders solve this problem! Since the bottom pin that is labeled "3" is the ground pin, all of the faders can share the common ground rail on the breadboard!

![](https://cdn-learn.adafruit.com/assets/assets/000/082/527/medium800/leds_IMG_6833.jpg?1571425437)

## Slide Pots

Each slide potentiometer will act as a voltage divider, with the Circuit Playground Bluefruit analog pins reading the wiper's varying output.

The pin assignments are as follows:

- **Pin 1 = 3.3VDC**
- **Pin 2 = wiper (to analog input)**
- **Pin 3 = ground**

Insert the three slide potentiometers into the breadboard as shown. You want the **pin**  **3** legs of all three pots to be placed into the **ground** rail (next to the blue line).

Insert pins **1** and **2** so there is a free row of breadboard pins above them, this is where you'll make the wired connections to the CPB.

![leds_IMG_6834.jpg](https://cdn-learn.adafruit.com/assets/assets/000/082/528/medium640/leds_IMG_6834.jpg?1571425460)

![leds_IMG_6835.jpg](https://cdn-learn.adafruit.com/assets/assets/000/082/529/medium640/leds_IMG_6835.jpg?1571425467)

![](https://cdn-learn.adafruit.com/assets/assets/000/082/531/medium800/leds_IMG_6836.jpg?1571426072)

## Wiring to Voltage

Use three small jumper wires (sometimes called "staples") to connect the **pin 1** of each slide pot to the red **+V** rail of the breadboard as shown here. Looking from the top down, **pin 1** is the pin on the left at the top of each slide pot.

![](https://cdn-learn.adafruit.com/assets/assets/000/082/532/medium800/leds_IMG_6837.jpg?1571426212)

## Connections to Circuit Playground Bluefruit

Now we can use alligator clip leads with male header pins to connect the sliders to the CPB.

Insert the **red lead** into the breadboard's top red **+V** rail.

Insert the **black lead** into the breadboard's bottom black **ground** rail.

Insert the **yellow lead** into the left slider's **pin 2** column on the breadboard.

Insert the **green lead** into the middle slider's **pin 2** column on the breadboard.

Insert the **blue lead** into the right slider's **pin 2** column on the breadboard.

Now, you can connect the alligator clips to the associated pads on the Circuit Playground Bluefruit:

- **red to 3.3V**
- **black to GND**
- **yellow to A4**
- **green to A5**
- **blue to A6**

![leds_IMG_6838.jpg](https://cdn-learn.adafruit.com/assets/assets/000/082/548/medium640/leds_IMG_6838.jpg?1571428060)

![leds_IMG_6840.jpg](https://cdn-learn.adafruit.com/assets/assets/000/082/549/medium640/leds_IMG_6840.jpg?1571428077)

![leds_IMG_6841.jpg](https://cdn-learn.adafruit.com/assets/assets/000/082/550/medium640/leds_IMG_6841.jpg?1571428087)

![leds_IMG_6842.jpg](https://cdn-learn.adafruit.com/assets/assets/000/082/551/medium640/leds_IMG_6842.jpg?1571428102)

![leds_IMG_6843.jpg](https://cdn-learn.adafruit.com/assets/assets/000/082/552/medium640/leds_IMG_6843.jpg?1571428117)

## Power

You can now power up the Circuit Playground Bluefruit board -- here I've used a 3.7VDC LiPoly battery plugged into the battery JST-SH port. You can also use an AA or AAA battery pack, or power over the USB port.

![](https://cdn-learn.adafruit.com/assets/assets/000/082/553/medium800/leds_IMG_6844.jpg?1571428140)

## Remote Color Mixing

Turn off the socket the MagicBulb is plugged into, then turn it back on. This is so that we drop any previous connect between the bulb and your mobile device, since the bulb cannot be connected to more than one Client device at a time.

The CPB's first NeoPixel will be lit yellow while it waits to find the bulb, then switch to blue when the connection is made. You'll also get a happy little beep-BEEP!

You can immediately begin mixing the bulb's colors using the faders for red, green, and blue.

Try flipping the CPB's slide switch left for half-brightness mode, or right for full brightness.

The A button will "mute" or "black" the bulb out, and the B button will set the bulb at full brightness while held.

![leds_IMG_0235.jpg](https://cdn-learn.adafruit.com/assets/assets/000/086/841/medium640/leds_IMG_0235.jpg?1578686826)

![leds_IMG_0236.jpg](https://cdn-learn.adafruit.com/assets/assets/000/086/842/medium640/leds_IMG_0236.jpg?1578686838)

![leds_IMG_0237.jpg](https://cdn-learn.adafruit.com/assets/assets/000/086/843/medium640/leds_IMG_0237.jpg?1578686848)

![leds_IMG_0238.jpg](https://cdn-learn.adafruit.com/assets/assets/000/086/844/medium640/leds_IMG_0238.jpg?1578686864)

![leds_IMG_0239.jpg](https://cdn-learn.adafruit.com/assets/assets/000/086/845/medium640/leds_IMG_0239.jpg?1578686877)

![leds_IMG_0240.jpg](https://cdn-learn.adafruit.com/assets/assets/000/086/846/medium640/leds_IMG_0240.jpg?1578686897)

![leds_IMG_0241.jpg](https://cdn-learn.adafruit.com/assets/assets/000/086/847/medium640/leds_IMG_0241.jpg?1578686904)

![leds_IMG_0243.jpg](https://cdn-learn.adafruit.com/assets/assets/000/086/848/medium640/leds_IMG_0243.jpg?1578686911)

Now you can have fun mixing your colors remotely!

https://www.youtube.com/watch?v=qEhtbHLAYho


## Guide Products

### Circuit Playground Bluefruit - Bluetooth® Low Energy

[Circuit Playground Bluefruit - Bluetooth® Low Energy](https://www.adafruit.com/product/4333)
 **Circuit Playground Bluefruit** is our third board in the Circuit Playground series, another step towards a perfect introduction to electronics and programming. We've taken the popular Circuit Playground Express and made it even better! Now the main chip is an nRF52840...

Out of Stock
[Buy Now](https://www.adafruit.com/product/4333)
[Related Guides to the Product](https://learn.adafruit.com/products/4333/guides)
### Slide Potentiometer with Plastic Knob - 35mm Long - 10KΩ

[Slide Potentiometer with Plastic Knob - 35mm Long - 10KΩ](https://www.adafruit.com/product/4271)
_Slip slidin' away&nbsp;  
Slip slidin' away&nbsp;  
You know the nearer your resistance&nbsp;  
The more you're slip slidin' away_

If you're tired of the regular-old-twisty potentiometers we carry, why not _slide_ over and try this slide pot?...

In Stock
[Buy Now](https://www.adafruit.com/product/4271)
[Related Guides to the Product](https://learn.adafruit.com/products/4271/guides)
### Half Sized Premium Breadboard - 400 Tie Points

[Half Sized Premium Breadboard - 400 Tie Points](https://www.adafruit.com/product/64)
This is a cute, half-size breadboard with&nbsp;400 tie points, good for small projects. It's 3.25" x 2.2" / 8.3cm&nbsp;x 5.5cm&nbsp;with a standard double-strip in the middle and two power rails on both sides.&nbsp;You can pull the power rails off easily to make the breadboard as...

In Stock
[Buy Now](https://www.adafruit.com/product/64)
[Related Guides to the Product](https://learn.adafruit.com/products/64/guides)
### Small Alligator Clip to Male Jumper Wire Bundle - 12 Pieces

[Small Alligator Clip to Male Jumper Wire Bundle - 12 Pieces](https://www.adafruit.com/product/3255)
For bread-boarding with unusual non-header-friendly surfaces, these cables will be your best friends! No longer will you have long strands of alligator clips that are grabbing little wires. These compact jumper cables have a premium male header on one end, and a grippy mini alligator clip on...

In Stock
[Buy Now](https://www.adafruit.com/product/3255)
[Related Guides to the Product](https://learn.adafruit.com/products/3255/guides)
### Breadboarding wire bundle

[Breadboarding wire bundle](https://www.adafruit.com/product/153)
75 flexible stranded core wires with stiff ends molded on in red, orange, yellow, green, blue, brown, black and white. These are a major improvement over the "box of bent wires" that are sometimes sold with breadboards, and faster than stripping your own solid core wires. Makes...

In Stock
[Buy Now](https://www.adafruit.com/product/153)
[Related Guides to the Product](https://learn.adafruit.com/products/153/guides)
### Fully Reversible Pink/Purple USB A to micro B Cable - 1m long

[Fully Reversible Pink/Purple USB A to micro B Cable - 1m long](https://www.adafruit.com/product/4111)
This cable is not only super-fashionable, with a woven pink and purple Blinka-like pattern, it's also fully reversible! That's right, you will save _seconds_ a day by not having to flip the cable around.

First let's talk about the cover and over-molding. We got these...

In Stock
[Buy Now](https://www.adafruit.com/product/4111)
[Related Guides to the Product](https://learn.adafruit.com/products/4111/guides)

## Related Guides

- [Adafruit Circuit Playground Bluefruit](https://learn.adafruit.com/adafruit-circuit-playground-bluefruit.md)
- [Ladyada's Toolkit](https://learn.adafruit.com/ladyadas-toolkit.md)
- [Wireless Image Transfer with Circuit Playground Bluefruit and E-Ink Gizmo](https://learn.adafruit.com/wireless-image-transfer-with-circuit-playground-bluetooth-and-eink-gizmo.md)
- [Generating Text with ChatGPT, Pico W & CircuitPython](https://learn.adafruit.com/generating-text-with-chatgpt-pico-w-circuitpython.md)
- [Infinite Text Adventure](https://learn.adafruit.com/infinite-text-adventure.md)
- [Circuit Playground Bluefruit NeoPixel Animation and Color Remote Control](https://learn.adafruit.com/circuit-playground-bluefruit-neopixel-animation-and-color-remote-control.md)
- [Wooden NeoPixel Xmas Tree](https://learn.adafruit.com/wooden-neopixel-xmas-tree.md)
- [Adafruit Feather HUZZAH ESP8266](https://learn.adafruit.com/adafruit-feather-huzzah-esp8266.md)
- [Make It Hot or Cold](https://learn.adafruit.com/make-it-hot-or-cold.md)
- [Circuit Playground Bluetooth Cauldron](https://learn.adafruit.com/cpx-cauldron.md)
- [Cardboard Box for Circuit Playground Express](https://learn.adafruit.com/cardboard-box-for-circuit-playground-express.md)
- [Snow Globe with Circuit Playground Bluefruit](https://learn.adafruit.com/snow-globe-bluefruit-cpb.md)
- [Which CircuitPython Board is Right for You?](https://learn.adafruit.com/choose-your-circuitpython-board.md)
- [micro:bit Lesson 2. Controlling LEDs on Breadboard](https://learn.adafruit.com/micro-bit-lesson-2-controlling-leds-on-breadboard.md)
- [Bluefruit Luminary Lanterns with Capacitive Touch](https://learn.adafruit.com/bluefruit-luminary-lanterns-with-capacitive-touch.md)
- [CLUE Metal Detector in CircuitPython](https://learn.adafruit.com/clue-metal-detector-circuitpython.md)
