Je t’embrasse Salutations from Silicon Valley, California

5Nov/150

The Human Glowstick – Part 2

Even though I began this project in August, attempting to adapt a OctoWS2811 implementation to be wireless; controlled by my phone...

What I'm actually going to walk through here is the end result. Which is simply a Adafruit WS2801 implementation on top of the Adafruit nRF8001 "callbackEcho" demo sketch.

PLEASE NOTE: At the time of writing this, the Adafruit WS2801 library does not include the Color() method... and as such, I branched it, created the method, and have made my modified version available on GitHub: Here (in all likelihood the change will have been merged into their mainline by the time you are reading this)

To give you an accurate idea on the scope of the software, remember that there are 4 parts to this project:

  1. The LEDs (238x WS2801 modules)
  2. The Bluetooth LE Module
  3. The Fan control (MOSFET)
  4. The Sound Detector

Whenever I start a project like this, I always try to make sure I have the basic understanding of any one component correct before moving on. (That's why each of those links above refer to a test that specifically targets one thing at a time).

One interesting tidbit that I continually forget: If you want to run your project without a console attached, you should probably not wait for a console to be attached... Basically, many Arduino example sketches run a setup() something like the following:

void setup(void)
{
    Serial.begin(9600);
    while(!Serial);
    Serial.println("Setup complete");
}

Only trouble is that when I take this setup into a costume, it will STILL require me to connect a serial console to it before I can continue past that while loop. It can be incredibly helpful to know that your sketch wont start till you connect the console to it... but on the other hand, you can spend an awful lot of time debugging why your sketch is not running when you "hide it away in your project"... but then mysteriously runs when you "look at it"...

Anyway...

Adafruit Color Picker iOS App

As the bare-minimum "glowstick" costume, you have to be able to glow... and given that the previous tests 1 & 2 above both passed... I decided to create the bare-minimum program using the Adafruit Controller ColorPicker.

What this allowed me to do was create another simple test program:

The nRF8001 + WS2801 Color Picker Test

Basically the only educational part of this demo is the breakup of "color picking" to "color setting" (the first being the action done on the App, and the second being the action done by the Teensy 3.2 to the WS2801 LED modules)

The main idea is to never block the main loop. An example of how I do this is to make sure that, instead of using delay functions, I instead just return to the main loop until a certain amount of time has passed.

Another example is inside the mechanism of color-picking. Every loop() starts with reading inputs (like the color #FF0000) and setting modes (in this case seeing a "!C" prefix in the BLE buffer immediately sets the mode to "color picker"). Every loop() ends with implementation of a single mode.

Comments (0) Trackbacks (0)

No comments yet.


Leave a comment

No trackbacks yet.