Home Creators Posts Import Register Favorites Logout

Content

Hi folks! 

For my first ER tech puzzle of 2020, I've just made this tutorial explaining how to create your own "Mastermind" electronic puzzle game using an Arduino. Players must determine a secret code (which can be numbers, letters, or symbols) by making a series of guesses. After each guess, segments of a Neopixel WS2812B LED Ring light up to let them know the number of elements in their guess that were completely correct, and those that were in the secret code but appeared in the wrong position. By refining their subsequent guesses, players can determine the correct secret code. If you were to use this puzzle in an escape room, this code could be the combination to a 4-digit padlock or could trigger a relay to automatically de-activate an electronic maglock, for example.

I've made a few changes to the rules of the original Mastermind board game, and I talk about these in the first few minutes of the video. Although I was talking in the context of this specific game, when designing games for escape rooms I think it's always good to think about issues like accessibility (in this case, colour-blindness), and also whether it's appropriate to have constraints like limits on the number of guesses that players can make -  how you would enforce that, or what the consequence would be. In general, I've found that if you take an existing game and move it into an escape room context, you often need to simplify it a lot!

In addition to visual feedback provided to players via the LED ring, the Arduino also creates a JSON data packet after each guess which is sent via the serial connection. This can be read by the serial in node of escape room control software such as Node-RED and used to show a panel on a gamesmaster's dashboard representing the state of the puzzle, any guesses made, and the feedback players received. This allows a GM in an control room to track the players' progress throughout the room, which puzzles they have solved, and give them appropriate hints if the get stuck. If you don't have or use such a system, that's fine - the game will work completely fine standalone!

Timings

00:00-04:50 Introduction, Demonstration, and Design

04:51-11:16 Wiring

11:17-37:27 Arduino Code

37:28-41:12 Integration with Node-RED Escape Room Control Software

41:13-42:08 Wrap-up

Components Used

Arduino Nano: https://www.banggood.com/custlink/mDmvNgpA7O

MAX7219 4x 8x8 Matrix Display: https://www.banggood.com/custlink/GDvKsgCMKm

WS2812B 24LED "Neopixel" ring: https://www.banggood.com/custlink/K3KmngpAwf

5V relay module: https://www.banggood.com/custlink/mDD3bOqeP5

12V cabinet-style failsafe maglock: https://www.banggood.com/custlink/vvmmNaz4Sm

Arcade pushbutton switch: https://www.banggood.com/custlink/GKvKb4JQw5

Arduino Code, wiring diagrams, and Node-RED flow

https://drive.google.com/open?id=1rjzWVPaoHp8DyLJFB64yIjGb7ENUtQC-

As always, thankyou for your support, and please ask if you have any questions!

Files

How To Create An Arduino Escape Room Mastermind Puzzle

This is a video tutorial explaining how to create your own "Mastermind" electronic puzzle game using an Arduino UNO. Players must determine a secret code (which can be numbers, letters, or symbols) by making a series of guesses. After each guess, segments of a Neopixel WS2812B LED Ring light up to let them know the number of elements in their guess that were completely correct, and those that were in the secret code but appeared in the wrong position. By refining their subsequent guesses, players can determine the correct secret code. If you were to use this puzzle in an escape room, this code could be the combination to a 4-digit padlock or could trigger a relay to automatically de-activate an electronic maglock, for example. In addition to visual feedback provided to players via the LED ring, the Arduino also creates a JSON data packet after each guess which is sent via the serial connection. This can be read by the serial in node of escape room control software such as Node-RED and used to show a panel on a gamesmaster's dashboard representing the state of the puzzle, any guesses made, and the feedback players received. This allows a GM in an control room to track the players' progress throughout the room, which puzzles they have solved, and give them appropriate hints if the get stuck. To download the Arduino code, wiring diagram, and additional resources for this and all my other escape room tech projects, please go to https://www.patreon.com/playfultech Timings --- 00:00-04:50 Introduction, Demonstration, and Design 04:51-11:16 Wiring 11:17-37:27 Arduino Code 37:28-41:12 Integration with Node-RED Escape Room Control Software 41:13-42:08 Wrap-up

Comments

Danielle Jackson

Hello Alastair! I’m having some coding trouble. I am using 4 LED rings to do what you do with one. Mostly because I want it to light around the push button of the bleach number. But I cannot figure out how to make that work. Any thoughts? And one other question, is it possible to Add in a program button so as to change the combination to something else without having to attach the Arduino to the computer again?

Kadir Maran

Hi Alastair! Thanks for sharing this! I recreated your project, and works great (apart from the issue with button 1 controlling display 4). I am wondering; would you be kind enough to share what code I need to add to make the LED's go red when there are no correct guesses? I am planning to use this with a lot more symbols and this feedback would be really good to have for the players, otherwise they don't get any feedback from pressing "submit" when all the guesses are wrong. Thanks!

tadziu_91

I don't know why communication between Arduino and Node-RED was dead until I changed in the Node-RED function node from var propid = flow.get("payload.id"); to var propid = msg.payload.id; The problem was that flow.get() cannot read nested properties from msg.payload and using it caused the "Invalid context key" error. After switching to msg.payload.id, Node-RED was able to correctly parse the incoming JSON from Arduino, update the global state, and the dashboard started showing the live guesses and results.

Griffin Trenbeath

This is so cool! I can't wait to tinker with this! I'm already thinking about putting on an OLED display rather than the neopixels, and a joystick module over the momentary switches. Thank you so much!!

Markus Stroschein

Hey Alastair, nice work as always. Have you ever mentioned how you connect all the puzzles to the host pc? In my rooms everything is connected via a can bus + one host arduino with a serial connection to the raspberry pi. But those can messages are not very intuitive, so it would be nice to use json files. What do you think would be the easiest way of updating the communication?

Nick Powley

Hi Alastair, nice puzzle with excellent code structure. I built this today but stupidly I forgot that using a Nano and the Neopixel ring I needed to use a higher current PSU rather than tap off the Nano. So it managed to vaporise the Nano regulator and destroy the WS2812 ring!!! Doh...my fault entirely it worked fine until I got the solution correct and the current pull on the regulator was too great. I'm adding this to an escape room briefcase I've built and it looks nice. Just as well Amazon can deliver a new Neopixel ring tomorrow currently using a 4 strip with modified code. Question for you...how do I use the "randomised" code function. I assume I cant just // out the fixed code line and need to call the randomise function? <<>> Ooops sorry I read the code again properly and found the line that needs to be uncommented. FYI I amended the Code to display 4 different colours in the ring after the correct solution is found. Each collared neopixel added together is 1/4 of the final four digit code... works nicely as the random function makes it a little more fun and the coloured ring looks cool. Thanks again for a nice project.

Rares

I just finished the setup it work great

Tony Chin

HI Im new to this group and just getting into this could anybody tell me how big of a 12 volt power supply I would need for this?

Hal Woods

Super cool puzzle. I hope you and yours are safe and happy. I put this together and have a weird bug. It displays it on the Matrix correctly but it is in reverse order as on the serial monitor. If i switch the button pins it displays it correctly on the serial monitor but in reverse on the matrix. I tried to look up fixes as I'm sure its something simple, but I'm out of luck. Any idea on the issue? Many Thanks in advance.

Hal Woods

thanks so much for the response. It is a different display and plugs in on the right hand side. I went ahead and bought individual displays to fix the problem. The problem is that the left button controls the far right display. If i change the the button order in the sketch they control the correct display but show the wrong order on the serial. I'm going to look at the link you posted for future reference. as always thank you so much for your projects and help. I have learned a ton doing these projects.

Javier

Hi, I'm new to this world, I love your work, they are impressive and I just did all the installation but it does not work correctly, on the displays it marks the numbers but when I press the validate button it does nothing and also the relay is always active , the ring also does not light, some help please

Jonathan Greiner

Hey Alastair, I'm new to these posts and can honestly say these have been great to review. I am a newb to an extent here with electrical engineering. I am curious, what size capacitor are you using for the neopixel ring? Thanks!

Walter

hi Alastair, i can include the librarie, but i cant include de src, please help me

Simon Robinson

Hi Alastair, I have mirrored your set up and everything works other than a slight problem with a 4 x MAX7219 led matrix. Position 1 is the display with the header plugged in from the arduino. This is confirmed by using the default secret code of 0 and getting the expected response. However everything is upside down and I can seem to find a reason why or a good solution. I can flip the display and it lo oks fine but this means position 1 is now on the far right and the positions are backwards, 4-3-2-1. I have seen some solutions online for this but they do not match the library being used in this example. I think I could manually flip the font.h but this seems very manual and I have to assume someone else will also end up down this path. The display is from amazon, i can share a link but I don't think there is any relevant information there. Thank you, Simon

Johan Hellemons

Good morning Alastair, greetings from Holland. You realy got me inspired with your posts, I love them. I am new to working with the Arduino and everything else for that mather, and I have a problem I can't solve: I can't get the Matrix to work. The only thing that I can get it to do, is to color complete red, or sometimes it gives lights in random order. I can't get the buttons to change anything. whta could be the problem? I think I wired things just like you explained. Hope you can help me

Johan Hellemons

I double checked, they should be right. Now i am having a problem with the SRC/LedControl.h file, I keep getting the message No such file or directory. could this be linked to my problem? and how can I solve it? I am really new to this but i have tried everything

Johan Hellemons

it's exactly like you descriped....do i have to put the files somewhere else maybe? (again, i am really new to this)

Johan Hellemons

I don't know how, but now it works with the original code...but the matrix still does not work. I only attached 1 button, wil it work only if I use all buttons ? the connections are like this: ground to ground/VCC to 5V, Din to A1, Clock to D13 and CS to A0 (sorry to bother you, but i really would like it to work, it's my first project)

Johan Hellemons

yep. The first time i wired the matrix to the arduino just like in your video, but the pins are not in the same place, so it did not work then at all. Could it be that I destroyed the matrix by doing that? Ground and 5V where not correct. Then i need to order a new one. And how do you attach the wires to the LED ring? Soldering? it seems so fragile

Johan Hellemons

I don't trust the Matrix Module...if you don't have any other solutions (i don't want to waste your time) I will order a new one and see what that one does.

Johan Hellemons

Hi Alastair, it's me again....i have got a new Matrix Module, what should I see when i hook it up to the Arduino? as for now I don't see anything, it doesn't work....I only got this wired, nothing else yet

Johan Hellemons

Good morning Alastair, the Matrix Module works, but I get the numbers upside down, can you help me solve this? or does this not effect the game and can I use it upside down and change the buttons so the correct one changes the correct number?

jelle peters

Hi Alastair, i wanted to recreate this project. got all the components and everything is working except the led ring. it lights up, but always full bright white. when i tested my led ring with an esp8266 and wled it worked as expected, but in your code it only turns on full white. do you have any idea what the cause of that may be?