In this Instructable, I will explain how to create a color changing light display which is controlled remotely via Bluetooth using an Android (Samsung, Google, etc.) or Apple smartphone or tablet.This is an inexpensive project, great for youngsters, and the bright colorful displays really attract attention.
More importantly, however, the project will help the builder understand the security weaknesses of Bluetooth, and be a foundation for other Bluetooth projects.
This popular wireless transmission method is common for "Personal Area Networks." These networks of computing devices are given this name because they are often very personal and nearby; including smartphones, tablets, wearables (wrist watches and health devices), multimedia (smart TV's and Home Theater), automotive (hands free and music streaming), and access control (door locks and alarm entry systems).
Step 1: This Instructable Has Been Quality Tested!
Ten high school students from Instructor Paul Lathrop's "Mechatronics" class thoroughly tested this instructable for quality and ease of use. This was done during a field trip to a nearby university, where students had approximately two hours to complete the construction, testing, and write-up.
"Mechatronics" is the combination of electronics and mechanical devices that are controlled by electronics. Usually associated with manufacturing and robotics, this topic of study also includes wireless communications since it forms the foundation of the Internet of Things (IoT). More applicably to these students is the study of the IIoT, or the Industrial Internet of Things.
Step 2: Parts List
In this graphic, you can see a mini tool box created for each pair of students constructing the project, and is definitely is a good idea to have a storage plan for these delicate electronic components.
Although you could certainly keep all of the supplies in your "scissors and scotch tape" drawer in the kitchen, the parts will be easier to find and last longer if you buy an inexpensive partitioned box from Walmart or Amazon.
The remainder of the parts are from the Italian http://Adafru.it website, and are all very reasonably priced. The website is easy to search, so I will not provide deep links (since they tend to break over time). These components include:
Circuit Playground (Classic)
Flora Bluetooth LE Module
USB to USB mini cable (for the Circuit Playground)
5 sets of alligator to alligator cables (to connect the Bluetooth module)
Optional: AA x 6 Battery Holder and 6 AA Batteries.
Optional: Two alligator to alligator cables to connect mobile power.
Step 3: Installing the Software on Your PC
The following instructions detail the steps for the environment used (Windows 10, currently available versions of software) but you can use more recent versions as things move forwards. The software setup is as it is largely described in the Adafru.it "Learn" page entitled "Circuit Playground and Bluetooth Low Energy."
1 - Install the Integrated Development Environment (IDE)
Here we used arduino-1.8.4-windows, available to download from the aforementioned website, as well as from Arduino.
2 - Install the Circuit Playground drivers
Here we used adafruit_drivers_22.214.171.124 from the aforementioned website.
3 - Open the IDE
The IDE is called "Arduino", and under File -> Preferences insert the following "Additional Board Manager URL" https://adafruit.github.io/arduino-board-index/package_adafruit_index.json
4 - Say OK and then close and re-open the IDE
5 - Connect the Circuit Playground device with the Micro USB
• See that it powers up and runs the default program "Circuit Playground Firmata"
• Rainbow sequence of lights
• switch near battery power jack reverses order
• one of the buttons plays a note for every color
6 - Unzip the Circuit Playground Library
Unzip the Circuit Playground Library into the Documents -> Arduino -> libraries folder “Adafruit_CircuitPlayground-master”
Once unzipped, remove the suffix "-master" from the folder name
7 - Unzip the BlueFruitLE Library
Unzip the BlueFruitLE Library into the Documents -> Arduino -> libraries folder “Adafruit_BluefruitLE_nRF51-master”
Once unzipped, remove the suffix "-master" from the folder name
8 - Stop and restart the IDE, and load the Circuit Playground Board Type
• Tools -> Boards -> Board Manager
• Search for type "Contributed" and keywords "Adafruit AVR"
• Install the "Adafruit AVR Boards" (latest version)
• stop and restart the IDE
9 - Test the Circuit Playground with a demo program
Connect to the Circuit Playground connected via USB
• Tools -> Boards -> Circuit Playground
• Tools -> Ports -> Appropriate COM port
• Download a demo program
• Files -> Examples -> Adafruit Circuit PLayground -> demo
• Compile and upload (can use the "right pointing arrow" button to do all)
10 - Test the demo program, and you're done!
• See that the Circuit Playground is blinking in rainbow sequence
• Switch causes notes to be played (please turn it back off)
• Red download LED blinks the timing rate Communicate with the Circuit Playground via Text Interface
• Click on the "Serial Monitor" button in the IDE
• Looks sort of like a magnifying glass in the upper right of the demo program window
• You may wish to turn off auto scroll to get a better look
Step 4: Connect the Bluetooth Module
Connect the BlueFruitLE module to the Circuit Playground Module
The pictures above show the complete connection (batteries are optional and can be added on later). The specific steps are as follows:
Unuplug from USB
• Connect as follows [also see pictures]
o Circuit Playground 3.3V to Flora Bluefruit LE 3.3V (red wire).
o Circuit Playground GND to Flora Bluefruit GND (black wire).
o Circuit Playground serial TX to Flora Bluefruit serial RX (yellow wire). Double check you connect TX to RX and not TX to TX!
o Circuit Playground serial RX to Flora Bluefruit serial TX (green wire). Again double check you connect RX to TX and not RX to RX!
o Circuit Playground #12 to Flora Bluefruit MODE (white wire). You can actually use any of the other numbered pins on Circuit Playground for this mode switch connection, however you'll need to modify the examples to use the pin number. For simplicity stick with pin 12 so you don't need to modify the code.
Reconnect to USB
Both Circuit Playground and BLueFruitLE should be powered up (latter has red blinking light)
Step 5: Download the Software to Control Lighting
One software you will download to your your smartphone or tablet (the BlueFruit app), and the other software you will download to the device you created (the CPlay_NeoPixel_Picker).
1 - Download BlueFruit app
• Download BlueFruit app on smartphone that supports BlueToothLE communication (ex: iPhone, iPad, Samsung)
• Here is a picture of the app and the search word used to find it on the Apple App Store. it is similar on the Google store and elsewhere.
2 - Load Neo-Pixel software on Circuit Playground
• File -> Examples -> Adafruit Bluefruit LE nRF51 -> cplay_neopixel_picker
• Upload to your device
Step 6: Control the Lights With Your Smartphone App
Use smartphone to connect
· After connecting, update the firmware if requested (pick latest version)
· NOTE: This is communicating straight to the Bluefruit LE
· May have a weird name first time re-connecting
· Use "Controller" after connected (not NeoPixels)
· Play with Color Picker (shade and brightness) and Control Pad (number of lights that are on)
OPTIONAL: Connect battery power instead of USB power (from the PC) to take your device on the go!
Step 7: Bluetooth Security
The students had fun trying to hack and get hacked. Many practical jokes can be created with a box full of Bluetooth connectivity, but it could also obviously get into the hands of malicious users.
Try these "fun hacks" to see how they work.
- How far away can you get before the Bluetooth signal is lost? Hint: it could be up to 50 meters - or about half a football field - but depending on transmission power, antennas, electronic interference and architectural building materials (not to mention that colleague making popcorn in the microwave) - your results may vary :-)
- Who is "Quick-draw McGraw?" See if you can take over the light colors before your friend does. Is the first person to connect the controller, or can more than one person control the lights?
- What other Bluetooth devices are in range of your controller? Is the device you built the onle visible Bluetooth device? Hint: Probably not!