Lost in the Maze
Last november, me and two friends (Alexandre and Nuno) had the fortune of attending yet another cool Codebits edition in Lisbon.
Being me the computer guy teamed with these two electronics guys, we had to find some idea to join forces.
THE IDEA? Remotely control a servo-driven maze.
So we hooked together two servo motors like this:

This made it possible to rotate the platform in two different axis.
We handcrafted a cardboard maze to use on top, but our motors couldn’t handle our first attempt, too much weight on the bottom servo. We had to remove half its original size to have some control over it.
Because we didn’t want this setup relyant on having a full-powered computer around, we had an Arduino powering and controlling these motors and a Raspberry Pi serving as webserver.
We printed a QRCode pointing users to a webserver we had running on the RaspPi that was getting the phones’ accelarometer data to drive the maze around. Ended up getting the accelerometer data using the following JS code:
if (window.DeviceOrientationEvent) {
window.addEventListener("deviceorientation", function () {
alpha = Math.round(event.alpha);
beta = Math.round(event.beta);
gamma = Math.round(event.gamma);
tilt(alpha, beta, gamma);
}, true);
} else if (window.DeviceMotionEvent) {
window.addEventListener('devicemotion', function () {
rotation = event.rotationRate;
if (rotation != null) {
arAlpha = Math.round(rotation.alpha);
arBeta = Math.round(rotation.beta);
arGamma = Math.round(rotation.gamma);
}
tilt(arAlpha, arBeta, arGamma);
}, true);
} else {
window.addEventListener("MozOrientation", function () {
tilt(orientation.x * 50, orientation.y * 50, orientation.z * 50);
}, true);
}
We even placed motion sensors for a starting and end point so we could measure users time between solving the maze.
You can checkout the final results in this video:
Having such a reactive system controlled by any iOS or Android device without having to install 3rd party software had many people surprised by our work. And that’s how we ended up getting the 5th place prize!

