I need to catch up. Some field upgrades for work required a lot more attention than originally planned and I ended up spending some nights working.
Anyway ... Last time, I got the BT part of the RedBear to work, and was able to send messages from an app on my phone to the Arduino.
In this post, I build further upon that, by processing the received messages and have them do something.
NeoPixels
My prop will use some addressable LED strips, often referred to as NeoPixels, to have the prop light up and create a burning fire effect.
In the Arduino online editor, I searched for Adafruit's NeoPixel library and loaded the strandtest example to test my LED strip.
Circuit
I've created a generic circuit diagram, including the BLE module, using a combination of the RedBear's onboard wiring and Adafruit's nRF8001 wiring guide.
The Arduino is currently powered by the microUSB input, as it is still connected for programming. Once the programming is done, the Arduino will be powered from the same power source as the LED strip.
Test
To test my LED strip, I loaded the "strandtest" example and had it run. Luckily, I purchased two strips, as the first one didn't work properly and only lit up 7 of the 150 LEDs.
The second strip worked as expected:
BLE + NeoPixel
The next step, was to combine the BLE UART functionality I already had, with the new NeoPixel capability. The general idea is to send characters via BLE UART and trigger different functions for colours and/or animations.
Code
I started merging my "ble_uart_project_template" sketch from last time, with some bits of the "strandtest" example, when I came across a "StrandtestBLE" sketch. Could it be that easy?
I looked at the code, and updated the pin definition to match my setup:
// define pins (varies per shield/board) #define BLE_REQ 9 #define BLE_RDY 8 #define BLE_RST 4
And sure enough, it worked!
This new sketch reads the incoming characters and triggers functions accordingly. All that's left to do, is implement my own animation functions, link them to the desired characters and we're good to go!
switch(current_state) { case 'a': colorWipe(strip.Color(255, 0, 0), 0); // Red break; case 'b': colorWipe(strip.Color(0, 255, 0), 0); // Green break; case 'c': colorWipe(strip.Color(0, 0, 255), 0); // Blue break; case 'd': theaterChase(strip.Color(255, 0, 0), 0); // Red break; case 'e': theaterChase(strip.Color(0, 255, 0), 0); // Green break; case 'f': theaterChase(strip.Color(255, 0, 255), 0); // Green break; case 'g': rainbowCycle(20); break; case 'h': rainbow(20); break; case 'i': theaterChaseRainbow(20); break; }
Test
A quick modification to the switch case to have some meaningful characters:
- o: off
- r: red
- g: green
- b: blue
switch(current_state) { case 'o': colorWipe(strip.Color(0, 0, 0), 0); // Off break; case 'r': colorWipe(strip.Color(255, 0, 0), 0); // Red break; case 'g': colorWipe(strip.Color(0, 255, 0), 0); // Green break; case 'b': colorWipe(strip.Color(0, 0, 255), 0); // Blue break; }
Here's the result:
Repository
I've created a gist to store my code in. This will be updated regularly to contain the latest version of the code.
Felo'fact
Last time, I explained that Felo'melorn has multiple appearances, but that's not all ...
Though purely cosmetic, Felo'melorn has four distinct colour variations.
Have a look:
{gallery} My Gallery Title |
---|
source: wowhead
Top Comments