This is a project in progress! I'll be finishing it soon for our ugly sweater contest. :)
It features a gaudy LED snowflake in the middle of my tacky, half-furry, half-electric-blue sweater. We can all get lazy during the holiday season, but hopefully I'll be able to stay focused by monitoring my EEG activity with this cozy sweater. Best of all, I get to feel like a fuzzy, festive Iron Man!
Of course, the first step is to select an appropriately horrible sweater. I found this one at the Burlington Coat Factory, a wonderland if you're looking for this sort of thing. My sweater looks kinda like it has brain wrinkles all over it, plus it matches my mohawk and coordinates with the reactorflake!
The Snowflake
This snowflake, a holiday trinket from Target, is powered with 6 volts (via 2 CR2032 3V coin cells). I'm going to trigger it wirelessly using a Pinoccio Scout, which provides a maximum of 3.7V. So, I need to use its original power source, but trigger it using the Scout. This is easily done using a transistor connected to a digital pin.
Right now, the 'flake has a built-in power switch in the line between the LED's negative leg and the battery pack's ground terminal. We're going to replace that with the transistor.
I'll have a schematic up soon, but since I'm deep in build mode right now, here's a simple description of what I'm doing:
Right now, the power flows (conceptually) from the positive terminal of the battery directly to the positive leg of the LED, which I'm assuming has built-in fader circuitry to change its colors. I assume, because I can't actually get the thing apart without destroying it. But no matter – the important part is, the power flows through the LED and then through the closed switch to the ground terminal of the battery.
What I've done is rip out the switch, with a little help from my Dremel. Now, it goes like this:
- Negative leg of LED is connected to "collector" leg of transistor
- Pinoccio's digital pin 2 ("D2") is connected to "base" leg of transistor. When that pin is turned off (LOW), no power flows, as though the switch were turned OFF. When it's turned on, power can flow, and the circuit is closed.
- The "emitter" leg of the transistor is connected to the battery's ground terminal, and to ground ("GND") on the Pinoccio Scout.
...And it works! :) I've sealed up the connection with hot glue, to stabilize it physically and keep the wires insulated from each other.
Snowflake Code
Next, we need to program my trusty Field Scout. I've decided that I'm going to trigger it with digital pin 2, so I save that as an output pin, which will be set LOW when the Scout turns on:
pin.save("d2", OUTPUT, LOW)
This creates a function, startup.d2, which will run when the Scout is powered on.
Next, we plug the yellow cable into d2 and the blue one into GND, and run this:
pin.write("d2", HIGH)
Success!! The flake begins flashing gaudy colors.
So, I'll save this (and its counterpart) as functions, for easy access:
function flakeon { pin.write("d2", HIGH) }
function flakeoff { pin.write("d2", LOW) }
With that tested, I unplug the Scout and work on attaching the two to my ridiculous sweater. I stuck the two wires through the sweater (it's loosely woven), and added a black twist-tie to secure the top of the flake to the sweater as well. (This keeps it from pitching forward.)
I then plugged the wires into the Scout, which gets tucked into the tank top I'm wearing underneath the sweater. In this way, all the load is supported separately from the wire connections.
The Brain
I won't reiterate the entire process for this, which can be read in full over at Mesh Your Brain. Basically, I took a NeuroSky MindFlex gaming headset and added a couple of wires so I could slurp out the brain data. Then, the Scout gets loaded up with a custom bootstrap sketch, MyBrain, which tells it how to read the data streaming from the MindFlex.
Since my comfy headset is currently out of commission (as I work to upgrade the hack for raw data), I think I'm going to stick this one in a holiday-friendly hat. But for now, here's the code that triggers the snowflake when my attention level goes above 75% (taking it easy in the "off-season"):
function flake { a = brain.attention; if (a > 75) { command.all("flakeon"); } else { command.all("flakeoff"); } }
The command.all allows for an expandable fleet of snowflakes :)
And to make it run once per second, starting when the Scout is powered on:
function startup { run flake, 1000 }
Since the Scout will freak out minorly – that is, throw an "Unexpected number" error – if it doesn't also have the flakeon and flakeoff functions, I've put these on as indicators that the signal is being sent. This is always useful in debugging issues that could be network-related:
function flakeoff { led.red(500); }
function flakeon { led.green(500); }
However, something's gone weird with this (probably my conditional statement in that first function there), and I'm debugging it now. Further updates as events warrant!
Comments