LED Track Puzzle Tutorial (Patreon)
Content
Hi folks! I hope you're all well. Here's a new escape room puzzle tutorial for you, which is all about LED strips (specifically WS2812B strips, commonly known as "Neopixels"). These amazing things are strips of individually-addressable LEDs which, with a little Arduino code and a 5V power supply, you can specify exactly what LED you want to light up, and what RGB colour you want it to have. They're frequently used to create flashy chase sequences or pretty puzzle decoration, but in this tutorial they're actually at the heart of the puzzle mechanic itself.
LED particles of different colours are spawned at the top of the track at regular intervals, and players must flick the correct toggle switches to guide them down through the various segments of strips to the matching elemental symbol at the bottom (similar to the way that a set of points are used to direct a train on a railway track). Once a certain number (configurable in code) of matching particles have been received at the end of each track, the puzzle is solved, and e.g. a relay can be activated releasing a maglock and granting players access to the next part of the escape room.
This puzzle is a hi-tech puzzle which could be themed to match many escape room scenarios - the LED particles could represent trains on a railway, packets of data on a computer network, or energy required to power a mysterious alien device, for example. It is easy to customise, and requires relatively little hardware, all of which can be purchased online for well under $50 (see links below).
Timings
00:00-02:22 Introduction and Demonstration
02:23-07:19 Explanation of Components Used
07:20-10:41 Wiring Diagram
10:42-52:10 Arduino Code
52:11- Wrapup, Theming, Customisation, and Accessibility
Hardware
In terms of hardware, this project is actually pretty straightforward. I'm using:
1x Arduino Nano (you could use pretty much any sort) ~$5 from e.g. https://www.banggood.com/custlink/KvKDUmhTqI
3 metres of WS2812B ("Neopixel") LED strips ~$15 from e.g. https://www.banggood.com/custlink/3G3KMmYfzN
1x 5V 40A Power supply ~$20 from e.g. https://www.ebay.co.uk/itm/DC-5V-24V-Universal-Regulated-Switching-Power-Supply-1A-60A-10W-480W-LED-3D-PSU/372784363144
4x Toggle Switches ~$5 from e.g. https://www.banggood.com/custlink/GmD3UDhuuG
2x 10V 1000uF capacitors
1x 330Ω resistor
Software
The software - i.e. the Arduino code - is where all the magic happens in this project. I'll explain all the code line-by-line in the video, but it includes some relatively advanced coding concepts, including:
Custom C struct to define the related properties of each particle
Multidimensional arrays to describe the track of LEDs
Object pooling to avoid creation/destruction of objects at runtime (bad for memory management of constrained-memory devices like Arduinos)
Sub-pixel animation to create smooth transition between LEDs
That's quite a lot to take in, so please don't worry if you don't get it on the first go through! I'll put up the code download in a separate post shortly for Patreons to download, and I've tried to comment it as thoroughly as possible so do take your time as you work through it - and as always please ask if any questions! If you adapt this to your own projects, I'd strongly recommend jotting down on a piece of paper exactly how your network of LEDs is connected and indidually numbered, in much the same way as I did in the comments at the top of the code - you'll find it really helpful if you need to debug behaviour later!
I hope you like it!