Last weekend, I put together a light panel with a QR code etched on the front. Scanning the code triggers a sequence of events that causes it to light up. The following video demonstrates it in action. (I’ve blurred the QR code in case this hits Reddit, to better limit this to people within visual range — whether in person or on video calls — and not every rando with a mobile phone scanning the video.)
I can’t say this is an original idea. I recently ran across a new (to me) post on Twitter that has apparently been kicking around Reddit for a couple of years. It’s someone with a QR code made of LEGO and a smart lightbulb:
I liked the concept, but figured I could re-make it as a single unit. I also wanted to make it less anonymous, to make the activations more identifiable. If you scanned it, I wanted you to know that it was YOUR scan that caused it to light up and not somebody else’s. I decided I’d use color pairs, with an LED animation. At first I wanted to derive the colors from IP address, so that (as long as you didn’t hop to another address), you’d consistently have your own colors. I ditched that idea and went with random colors each time, given that my coworkers connect via VPN, which can often share an address. (I briefly considered distilling it from unique HTTP request headers, but that felt a little too close to the shady things that advertisers do.)
If you saw my previous blog post about getting the Feather Huzzah communicating with AWS IoT message queues, you now know what that was a lead-up to. This felt like a fun project that joins a broad set of skills including electronics, laser cutting, 3D printing, firmware, cloud services, software, and web technologies. The whole technology stack looks like the following.
- You scan the QR code with your phone.
- That leads to my own personal URL shortener, which redirects you to a website. (This lets me change the destination later, without re-etching another front panel.)
- The site loads and makes a background request to API Gateway.
- API Gateway triggers a Lambda.
- The Lambda runs some Python code that picks two random colors, passing them to the MQTT queue. Those colors are also returned up the stack to the browser, which presents them visually.
- The Feather receives the message.
- The QR panel lights up with the given color pair.
Some intentional constraints:
- The API Gateway limits the number of requests per second to only a couple (down from the default of thousands).
- The message queue is only 10 entries and will silently drop if it’s full. (The animation takes five seconds, so that’s an eternity of animations queued up.)
The project is not as well-documented as some of my other projects — particularly around the creation and permissions of the cloud pieces. It’s all in source control nonetheless. You can find it at https://github.com/BrianEnigma/QR_Panel