10 May 2016
The Magic Wand
Building on the Rememberaball I presented last week, and the endless possibilities of magic that can be done using BLE and sensors I decided to create a magic wand.
Designing the wand
I wanted to wand to look like a magical item, but I also wanted to be able to add any technology I want inside it.
Some interesting wands I found online and gave me design inspiration:
I user Rhineceros to design my desired wand shape. I then used the very useful command “contour” that generates layered outlines.
I laser cut a thin wood piece and used wood glue to glue it together.
Using glue and brown packaging paper, I cover the constructed wand to give a more natural look. I made extra wands in case something will go wrong, or in case I will want to use more than one in my final presentation.
I made a small slot at the top for the clear plastic ball holding the bean to sit in.
I sprayed the clear ball with a special spray to give it a frosted glass effect.
I borrowed this great BLE connected lantern from the kind Oren Lederman. It is connected to a Nrf51UART chip, and programmed to get string messages of the list [“ON”, “OFF”, “FADE”, “BLINK”].
The lantern was perfect for my wand. It has a magical look and since it’s controlled by bluetooth it is magical in itself.
I had to write to code to search for it, connect to it and send messages to it. I used the Node.js noble module for that.
Programming the System
I used Node.js to write a server that runs on my computer, connects to the wand and the lights, And starts different actions according to the wand movement.
The server has a buffer of 20 accelerometer readings.
Every 25 milliseconds it sends a request to the wand to get accelerometer data and updates the buffer.
This means that in every given moment I hold data about the last 0.5 second.
With this buffer mechanism I could do great things and very accurate gesture recognition.
Due to lack of time, I did not have a perfect gesture recognition logic ready for presentation.
Instead, I created a state - machine - the server holds a list of actions it can do. Whenever the wand starts a movement and then stops, a new action starts.
The server also connects to the lantern and sends it text messages (that is expects to get) to turn it On/Off/Fade.
Now I could direct a whole scene in advance, and the next thing in the scene would happen on a wand gesture.
This was inspired by Disney’s Fantasia.
There are so many other cool Node.js modules I can now use, to get more actions done by the wand. There is Node-email module, a Node-slack module, we can connect to other BLE device or to an Apple-TV, and much more.
All the code I wrote can be found in this github repository.