Mesmeric mirror

By Rob Zwetsloot. Posted

Looking to brighten a dark bedroom, Roberto Tyley decided to cast fresh light on the idea of a motion-sensing illuminated mirror

On reflection, he could have just bought a lamp. But after Roberto Tyley stood on one too many of his children’s toys in the dark corners of his bedroom, and decided it was time for some additional light, he was hit by a flash of inspiration.

Mesmeric mirror is one of the entries in our Top 75 Projects community vote!

What better way of illuminating the room, he mused, than a full-length portrait mirror that would shine brightly whenever anyone wandered by? One with individually controllable LED lighting that would directly respond whenever someone posed in front of it, perhaps? As light-bulb moments go, he admits it was certainly high on the wacky scale.

But Roberto saw the potential for both practicality and fun. “The idea was to have a mirror that would know if my children were waving their hands around,” he explains. “I wanted the lights to move and sparkle around their fingers as they did so.”


Roberto’s first decision was to put a Raspberry Pi at the heart of the build. He had only ever used the computer once before, to create a video demonstrating the speed of a tool he’d written to clean Git repositories. He liked the fact that the Pi was a fully specced Linux platform. “It meant I could use the tools and languages I was familiar with,” he says.

His next step was to research the best lighting, and he eventually chose Adafruit’s DotStar Warm White LED strips. “They are more expensive than simple strips, but they use a pretty straightforward wiring system,” Roberto explains. “Adafruit also supplies a nice Python library to control the strip from the Pi.”

 The sensor is visible up close

Motion sensing

From there, he looked for a way of detecting the presence of a person, before hitting on the idea of a laser rangefinder. “It occurred to me that if I had a laser rangefinder pointing straight down from the top to the bottom of the mirror, in the same axis as the LEDs, it could sense how high up anything was,” he continues.

This would allow the LEDs to light up to the height of a person, or work out if they were stretching their arm up, and illuminate further. “I decided to use the LIDAR-Lite rangefinder, which is a pretty cool but pricey sensor that encodes digital fingerprints into the bursts of laser light it sends out,” he tell us. “This means it can uniquely identify the pulses of light that bounce back, so it’s not confused by secondary reflections.”

To tie everything together, Roberto created a simple program in Python: “The code polls the laser rangefinder to work out if there is an object closer to the top of the mirror than the mirror base. If there is, it increments the brightness in an array that tracks how bright all the LEDs should be.” But it wasn’t entirely straightforward. Creating the body of the mirror proved a daunting task.

 The components fit neatly in the top

Learning by doing

“Before I started, I had zero woodwork skills – I’d been terrible at it at school,” Roberto admits. He watched several YouTube videos about making mirror frames (“the opposite sides really need to be the same length,” he laughs) and he also ended up buying all kinds of powerful tools to get really accurate mitre joints.

Still, it was worth it. During the grand unveiling, accompanied by the sounds of 2001: A Space Odyssey, he watched the delight on his children’s faces. “It had become an almost embarrassing addiction,” he says of the process. “But my children love it, and they show it off to their friends when they come round.”

From The MagPi store


Subscribe to the newsletter

Get every issue delivered directly to your inbox and keep up to date with the latest news, offers, events, and more.