Courtesy of Adafruit
Guide by Tony DiCola
Circuit Playground is an excellent all-in-one board for learning electronics, but did you know you can control Circuit Playground wirelessly from your phone or tablet? With the magic of Bluetooth Low Energy and a little helper like the Flora Bluefruit LE module you can start experimenting with wireless control of Circuit Playground today!
Adafruit's Bluefruit LE Connect apps for both iOS and Android provide a simple interface for controlling the digital inputs/outputs on Circuit Playground. Toggle digital pins high or low to control LEDs, relays, or other digital devices. Read digital inputs to detect when buttons are pressed or simple digital sensors activate. You can even control the color of the NeoPixels on Circuit Playground wirelessly from a few clicks in the app.
Best of all there's no soldering required for this project--just connect a few components with alligator clips and you're all set!
Before you get started you'll want to familiarize yourself with a few guides:
Continue on to learn about the parts needed to follow this guide.
To follow this guide you'll need the following parts:
If you're using the Flora Bluefruit LE module this project is very easy to put together and requires no soldering--just connect components with alligator clip wires as shown on the next page!
To connect a Flora Bluefruit LE module to Circuit Playground wire it up as follows:
Note if you're using a Bluefruit LE UART Friend the connections are the same but the MODE pin is labeled MOD, 3.3V is labeled VIN, RX is labeled RXI, and TX is labeled TXO. In addition you can ignore the other pins like CTS, RTS, and DFU.
One last very important step is to flip the mode switch on the Flora Bluefruit LE module (or Bluefruit LE UART Friend) into the DATA position. If the switch is in the CMD position the software won't work correctly so be careful to double check the switch is in DATA mode.
After wiring the Bluefruit LE module to Circuit Playground you'll need to do a small bit of software setup to run the examples.
First if you're new to Circuit Playground be sure to follow its guide to setup Arduino for programming the board. Make sure you can load some of the basic examples like blinking a LED on the board before continuing further. Also don't forget to install the Circuit Playground library in Arduino as the guide mentions.
Next follow the Bluefruit LE module guide to install the necessary Arduino libraries for using the module. In particular you need to install this library (use the library manager in Arduino to search for and easily install it):
That should be all the setup necessary to program Circuit Playground with sketches that use a Bluefruit LE module! The next pages explain example sketches to control Circuit Playground with the Bluefruit LE module.
Pin IO is a way to control the digital inputs, outputs, and more on Circuit Playground wirelessly from a phone or tablet. Right now only basic components like digital inputs, outputs, and even PWM (i.e. dimming an LED) are controllable with pin IO.
Pin IO works using the Firmata protocol to remotely control the Circuit Playground. Normally Firmata is used with a USB or serial connection between an Arduino and a computer. However by hooking up a Bluefruit LE module to the serial pins on Circuit Playground you can wirelessly talk the Firmata protocol to control Circuit Playground too. You don't need to write any code to control the board--just load the Bluefruit LE Connect iOS or Android apps!
To use pin IO mode make sure you've followed all of the previous pages in this guide and have a Circuit Playground wired to a Bluefruit LE module, and the Arduino IDE setup to program both Circuit Playground and the Bluefruit LE module.
Next install the following Arduino library (use the library manager to find it, filter to BLEFirmata and install the Adafruit BLEFirmata library):
Once the library is installed open the CircuitPlayground_nRF51822 example from the library in Arduino. This sketch implements the Firmata protocol and uses the Bluefruit LE module to listen for commands.
You don't need to make any modifications to the sketch to use it, however if you changed the mode pin from 12 to something else you will need to modify the BLUEFRUIT_UART_MODE_PIN define in the BluefruitConfig.h tab.
Upload the sketch to Circuit Playground and you should be ready to start controlling the pins with either the Bluefruit LE Connect iOS app or Bluefruit LE Connect Android app. If you haven't used the Bluefruit LE Connect app before be sure to skim the guide on its usage (although the guide is for iOS that application is very similar on Android).
Open the Bluefruit LE Connect application and look for a device called "BLE_Firmata". Click the Connect button to connect to the Bluefruit LE module.
Click the Pin I/O button (on the iOS app look at the icons on the bottom of the screen) to enter Pin IO mode.
After entering Pin IO mode you should see a list of the digital inputs & outputs on Circuit Playground.
You can tap a pin to see options like turning it into an input and reading its state, or turning it into an output and setting it to a high or low logic level.
Try turning pin 13 into an output and toggling it high or low. This pin is actually connected to the red LED on Circuit Playground and you should see it turn on/off as the pin toggles.
Some of the components on Circuit Playground work just with digital IO and pin control:
Try pushing the buttons or moving the slide switch--you should see the pin state change in the Bluefruit LE Connect application. That's all there is to the basics of controlling digital pins wirelessly with Bluefruit LE & Circuit Playground!
In addition to toggling pins on Circuit Playground you can also control the color of its NeoPixel LEDs wirelessly from a phone or tablet. The Bluefruit LE Connect iOS and Android apps have a special color picker mode which makes it easy to change pixel colors.
To use this NeoPixel control sketch make sure you've followed all the steps in this guide and have a Circuit Playground wired up to a Bluefruit LE module. In addition make sure you have the Circuit Playground and Adafruit Bluefruit LE nRF51 Arduino libraries installed as previously mentioned.
Next open the Arduino IDE and pick the cplay_neopixel_picker example from the Adafruit Bluefruit LE nRF51 library.
You shouldn't need to modify anything in the sketch, however there are some #define values near the top that can adjust the behavior like the intensity of the NeoPixel brightness. Also if you changed the mode pin from 12 to something else you will need to modify the BLUEFRUIT_UART_MODE_PIN define in the BluefruitConfig.h tab.
Upload the sketch to Circuit Playground and you should be ready to start controlling the NeoPixels with either the Bluefruit LE Connect iOS app or Bluefruit LE Connect Android app. If you haven't used the Bluefruit LE Connect app before be sure to skim the guide on its usage (although the guide is for iOS that application is very similar on Android).
On your iOS or Android device open the Bluefruit LE application. You should see a device called "CPlay_BLE" (sometimes in rare cases when the serial connection has too much noise you might see it called "Adafruit Bluefruit LE").
Click the device, then click the Controller mode (not the NeoPixel mode, that's a more advanced NeoPixel control system that isn't supported by this sketch).
Click the Color Picker at the bottom to enter the basic NeoPixel color picker control.
Choose a color, then click Send to send it over Bluetooth Low Energy to Circuit Playground. You should see the NeoPixels on the board light up the chosen color!
Finally go back to the Controller mode and select Control Pad at the bottom. Press the left arrow or right arrow to change which pixels are lit up.
That's all there is to controlling Circuit Playground's NeoPixels with a Bluefruit LE module & Bluetooth Low Energy!