Guide: Circuit Playground

This guide shows how you can program the Adafruit Circuit Playground Bluefruit to function as a remote control for the Shared Game Timer. Also, how to power it from a LiPo battery to make it nice and portable.

Overview

The Shared Game Timer has a open-ended bluetooth module that allow you to write to and read from Bluetooth Low Energy (LE) devices. These can be things like LED lights, buttons etc. In this guide, we will program the Adafruit Circuit Playground Bluefruit board to be a really cool little remote control.

Adafruit is an awesome electronics company based in New York but they sell world-wide. Their mission is to make electronics approachable and fun, and so they created the Circuit Playground, a perfect board to start playing around with electronics. It has 10 LEDs, two buttons, a switch, a little speaker and an accelerometer, all of which we will make use of in this guide!

You can power the board from a standard USB power pack, but to make this remote control easier to pass around a board game table, I will also show how I 3D printed a small enclose to hold the board and a small LiPo battery.

Components

The main component is of course the Circuit Playground Bluefruit board, and, if you will power it via USB, that is all you need. (and a USB power pack and a USB micro cable of course)

But, if you want to go portable, also get the thin LiPo battery.

  1. Adafruit Circuit Playground Bluefruit
  2. Lithium Ion Polymer Battery - 3.7v 500mAh

The Battery Holder

To make the board easy to pass around the gaming table, you want the battery and the board to be one unit.

You could go the McGyver route and simply tape them together with electrical tape... But, for a more graceful solution, 3D print this battery enclosure.

Assuming you don't have a 3D printer, maybe you can find one at your school, university or there may be a local company that allow you to print items? Failing that, there are many online companies that will happily print and send you items.

Here is the full guide to the Circuit Playground mount.

Note that the two mounting pegs were slightly too thick when I got my 3D printed mount, but it was easy to fix by sandpapering them down ever so slightly.

Programming the Circuit Playground

We will be programming the Circuit Playground using Circuit Python. Please follow the setup guide until you are ready to edit the code.py file.

Download and copy this code.py file to your board. You will also need to install the libraries imported at the top of the file, as well as edit the fields under # Constants and Setup

Download Circuit Playground's code.py file

When the code is saved, you should see a blue rotational animation of the ten LEDs, meaning it is ready to be connected to via Bluetooth.

Connecting it to the Shared Game Timer

The Shared Game Timer Bluetooth connectivity is quite open-ended, able to connect to many different devices. This flexibility also means that the process of setting it up can be a bit confusing. Below is both a written guide as well as a video walking through the steps.

Go to any Shared Game Timer game (feel free to create a toy one just to try it out), open the menu, open the Remote Control menu and click into the Bluetooth LE page.

Click the Device Configuration link.

If you have not yet added the Nordic UART service, click the Add New Service button, enter 6e400001-b5a3-f393-e0a9-e50e24dcca9e as the UUID, pick a nickname and then Save.

You should now see the Service in the list of services. Click the button and you should be asked to connect to the Bluetooth device. Assuming the pill button is still blinking blue, you should see it available named something like 'Circuit Playground' or 'CIRCUITPY'. Click it and then Pair.

You should now see two sections, Write Script and Action Mapping. Let's do them in order.

Where it says 'Write Script', enter this:

0 sgtState;sgtColor;sgtTurnTime%0A

What it basically says is, "0 milliseconds after triggering, send the current game state, color and current turn time, followed by the new line character. For example, it might send pl;ff0033;15000 . Give it a name (e.g. Adafruit Game Update) and hit Save.

Now look at the Action Mapping section. You should see the word 'Connected', which is the first thing the code we put into the Circuit Playground will send once it connects. Now, try pressing the left A button. You should see 'A' appear. Try pressing both A and B. You should see 'AB'. Now try to shake the plaground! You should hear a little beep, and the word 'Shake' appear.

This section shows all the events sent from the Pill Button to the Shared Game Timer. Now it is up to you to decide which events should correspond to which actions in the Shared Game Timer. Here is my suggestion, but you can enter whatever you want.

Keyword Action Description
Connect Poll Automatic at connection
AB Toggle Admin Left and Right button
A End Turn Left button
B Pass Right button
Switch Toggle Pause Switch toggled either way
Shake Undo When shaking the playground

For each message sent by the Playground, the Shared Game Timer will evaluate each of the action mappings in order and trigger the first one that contains the keyword.

This is why the keyword 'Switch' will match both 'Switch ON' and 'Switch OFF'.

This is also why we must put 'AB' above 'A' and 'B'. As a rule, the most expressive keywords should go at the top.

We are now all done to use the button! Go back to the Bluetooth Remote page, and you should see the Write Script and Activation Map we just created. Activate both. For the Write Script, click the 'Tick all checkboxes' button, and also tick the 'Whenever target state becomes active' as well as 'When Polled'. Finally, click Connect and you are now DONE! 🥳