Maybe you use the International Standard "Occupied" Signal: wearing your headphones when you don't wanna be bothered. But some people just don't respect that... and there will come a day when you'll forget your precious earbuds.
Enter this little USB-powered, gesture-controlled status indicator (and lamp!).
When you wave your hand over the Leap Motion controller, the LED turns on and tells your visitor those two little words: GO AWAY!!
First, obviously, plug the Leap Motion into your computer. It comes with a long cable so you can stick it in a tower or installation, but the menu-bar status indicator will show you that it's plugged in – on Mac, anyway.
With this, I'm using a TinyLily Mini, which is an Arduino that happens to be extremely small – and also sewable and washable. We won't be using those functions, although I suppose you could sew a nice office blanket that twinkles all over with a "GET LOST" pattern of LEDs.
That's not what we're doing, but... you could.
Plug the processor board into its USB adapter, and connect the assembly to your computer with a Micro USB cable.
Then, hook an LED up to digital pin 2 and ground.
Make a little paper sign to hang over it, or 3D-print an enclosure! (And share it with us!)
You'll need to install the Leap software and SDK, which requires signing up for an account.
Firmata is now included with new versions of the Arduino IDE. So, if you don't have it, go update. Then, upload the StandardFirmata sketch on your board (File > Examples > Firmata > StandardFirmata). For the TinyLily, I chose Board type "LilyPad Arduino". Check which serial port the Arduino is listening on.
After that, follow the directions to get Cylon up and running.
- Open up a terminal window and type
ls /dev/cu.*– this will bring up all your serial ports. You can easily copy the one for your Arduino and paste it into the JS code, replacing
/dev/ttyACM0. Mine was:
- For the TinyLily, which doesn't have a lot of through-hole pins, I subbed in digital pin
13for the LED pin.
- And finally, change
my.leap.comin the bottom function, or else you'll get an "undefined" error.
Running the script
Your Arduino, if it's still plugged in, is listening for commands over the USB serial port.
Go to the folder where you saved your LeapDuino script, and run:
Since this is your first time using Leap with Cylon, you'll probably get a couple of messages stating that you need to install libraries. That's normal. Just install them now:
npm install cylon-firmata cylon-i2c
(...and possibly others)
Now, run the script again and you'll be able to trigger the LED by waving your hand around over the controller! Put a little sign-hat on it, and send whatever message you need to.
Bonus Round: See the Data!
Want a glance at the Matrix code? Go ahead and install the Leap SDK.
Then, in your terminal, navigate to the samples folder: LeapSDK > examples
make to compile everything.
./sample and watch the data flowing around your fingers!
For something a little more readable, double-click JSONViewer.html in the samples folder. It'll open up a formatted version of the data, in your browser.