I am trying to combine two different plans or at least modify one to accomplish a specific outcome. Let me set the stage:
Portable escape room box with various puzzles each "enabling" the next. I have everything working with a Keypad puzzle, a connect the proper wire puzzle and an RFID card placement puzzle. The last puzzle I am working on is a toggle switch puzzle. I have two ideas to combine. The first is a somewhat old video from Playful Technology (Toggle Switch Escape Room Puzzle Tutorial - YouTube) where he has a fairly simple toggle switch puzzle where a resettable switch pattern is programmed to the eeprom and a relay is activated (or deactivated) when the proper "On-Off" pattern in the eeprom is met. That is working flawlessly, but I want a bit more.
I want it so the switches have to be thrown sequentially in a pattern with some sort of feedback to let the solver know they are on the right path, but also have them need to reset the toggles to "off" if they are wrong.
The topic (which was closed long ago) on this forum "Detecting switches in order" (Detecting switches in order - #7 by alto777) seems to be what I want, but the code derived in that discussion is for pushbuttons and not the toggle switches I have and want.
These are the toggles from Amazon and I like them because they have a nice bright LED on when the switch is on and would like to keep them or something like them.
Basically, the way Playful Tech wired everything is spot on. each switch shares a ground, each switch shares a 5 volt, but each switch is tied individually to an Arduino input. In this way, the switches light up when turned on and complete a circuit to tell the Arduino it is on or off. Perfect.
When I try the other code, which is more advanced then what I know right now, when the switches are off, the led is dim and when they turn on the leds are brighter. Not a huge deal, but not preferred. I tried modifying the code and I think I get most of the way there, but it does not operate like the WOKWI simulation at all. in that example, when reset or powered on, the red and green leds alternate then sit in a ready state. when I try it with my toggle switches wired the way I have them it immediately goes into a wrong answer where the red led blinks.
Again, I know some code stuff, but I get a bit lost where to find the issue that makes this work.
In my scenario, I want these switches to act like progressively turning on parts of a machine and powering up the wrong parts sends it into an overload and they need to start again. I am thinking a series of green leds, 5 in this case, where it will light up another when one is correct and some red leds to clear the green leds currently on and flash themselves until reset. once the proper sequence is realized, open a relay and move on.
Can someone assist me here? Let me if you need more information and I will try my best to post it.