Home Creators Posts Import Register Favorites Logout

Content

This is a very common tech puzzle I've seen in Escape Rooms - a series of toggle switches which must be set to the correct pattern of on/off states in order to release a maglock or activate some other device.

Now, you could create a basic version of this puzzle by just wiring the switches together in series - no microprocessor required - so that when set to the correct state they complete a circuit that powers the relay. However, in this tutorial I wanted to create slighly more configurable approach - by reading each switch state separately using an Arduino, you're able to dynamically change the desired solution state at runtime. And, by saving that solution to EEPROM, you can then store and reload that pattern - even if the Arduino is turned off!

00:00 - 02:45 Introduction and Demonstration

02:45 - 07:08 Wiring

07:08 - 20:46 Arduino Code

20:46 - 21:18 Wrap Up

To download the code or wiring diagram for this project, please go to https://www.patreon.com/posts/19260420 - thanks!

Files

Toggle Switch Escape Room Puzzle Tutorial

In this video I'll show you how to create a "Toggle Switch" puzzle, in which players must turn a series of toggle switches to the correct pattern of on/off states. The solution can be changed at runtime by simply setting the switches to the desired state and then pressing a button - this state will then be saved to the EEPROM of the Arduino, and will then be used as the puzzle solution from then on (even if the Arduino is powered off!). 00:00 - 02:45 Introduction and Demonstration 02:45 - 07:08 Wiring 07:08 - 20:46 Arduino Code 20:46 - 21:18 Wrap Up To download the code, wiring diagram, or additional information concerning this project, please see my Patreon page at https://www.patreon.com/playfultech - thanks!

Comments

Brian Vinciguerra

Was the situation with the constant cycling of the relay ever resolved. I tried to build this tonight and I experienced the same issue as others with the relay cycling continuously. I tried the suggestion of adding 10K resistors on the input pins and that didn't resolve the issue.

Edward Carter

Thank you for these videos I am learning Arduino and they are helping me a ton. I did want to let you know your wiring diagram doesn't match up with how you wired the switches on your puzzle.

leucosia

hello alistair, we find it or the big blue button and how it is called it, sorry I start in the arduino thank

Pascal Kaiser

Hey Alastair, i really like your arduino-based games and already did the valves and the wireconnect game. Now i tried to realize the idea of your toggleswitch-Game - but whrn i u packed muy switches they got 4 connectors not three. two are normally open, the other two normaly closed - but how do i now connect them according to your wiring. Or do I even have to change the code? Thanks a lot for helping again. pascal

FuriusP (edited)

Comment edits

2026-09-07 18:00 Hi Alastair, I am wondering if this can be done with an on/off/on switch. Do I have to use 2 digital pins for each switch or there is another way that saves me digital pins? Or it can't be done at all?
2019-11-20 13:50

Michel Bouchard

Hi, i tried to replace the switch by reed switch, but the relay constantly turning on and off... Do you have a solution to fix that ?

Óliver Novelles

Hi Alastair! Can I make that, once the puzzle is solved, instead of open a door, turn off another arduino system? Can I make it with the relay itself? Thank you so much!

Vagos Barlas

I took the idea a bit further...and made one that has 5 toggle switches and a button.....the button checks steps (i did it with 4 steps...4 leds...one for each step) and validates them against the saved correct values of each step...if a step is correct a led is turned on and you continue to the next step....continue like that until you get to the final step and unlock the puzzle. Next step to make it save each step to EEPROM using the leds in reverse to validate your 4 sets of data...that would be tricky....(not that i need to do it....but just why not?)

Vagos Barlas

Well actually was way easier than i thought it would be....the trick part was to compartmentalise correctly the EEPROM memory using the correct addresses to write and read the data according to each step of the puzzle ...but i was prepared and it took me 30 mins to write the code....Now it rocks!...Thanks Alastair for the inspiration and the original idea!...Keep up the GREAT work...i am a fan!

David Bodsworth

I have a puzzle similar to this (without the programming button though) with 9 switches, but I want to be able to solve the puzzle with the switches either way around (so 011100010, or 100011101). What would be the best way to do that? I was trying to simply add a second solution as an OR in the if part of the isPuzzleSolved, but realise now that doesn't work because that is checking each individual input and returning false as soon as it find one incorrect input.

Alastair Aitchison

(p.s. you can extend that to however many additional alternative solutions you want to add - just copy and paste the section of code at the bottom. There are more elegant ways to set this up, but I think this is probably easiest to understand what's going on - let me know if that doesn't make sense!)