Intro: How to Make a Puzzle Box With Arduino
For a project I had to design something interactive with an arduino. I chose to design a game with a puzzle box as component. In this how to I will explain how I made this box, as well as tips on how to modify it for other use cases.
Step 1: Required Components
For this project I used an arduino mega 2560 myself because I had a lot of leds and sensors to plug in. It is also possible with an uno or even smaller variants of arduino. It really depends on how much pins or processing power you need. In my case it was mostly convenience, because I could hook up a lot of stuff to test things without having to make modifications or calculations. I recomend using at least some LEDs buttons and sensors if you want to make a puzzle box. I used the following components:
-Arduino mega 2560
-5V DC motor
-4pin RGB LED
-9 pink LEDs
-seven segment display
-a lot of jumper wires
-some resistors of varying strenth, you need some for the leds and two for the seven segment display.
for the casing I used
The tools I used
-soldering Iron and solder
Step 2: Testing + Breadboard Prototype
Before you start you should test all your components by wiring them up to see if they work. This way you will know it is the code where you messed up, and you will not spend hours looking for the problem. Then proceed to wire everything as you need it to be. Usually I write some test code and run it while I am adding more components to make sure everything is in place before I actually begin with the more complicated stuff. If for some reason you need to change anything or if you want to add more components after all this is the best time to do it. In this stage I also swapped out my uno board for a mega board because of the flexibility it gave me.
In this stage I also looked at a ton of tutorials to finalize my design and how I wanted to use each component. Here is another good example of a nice puzzle box X
And here are some instructables on how to hook up certain components which I used as guideline to hook up mine:
Seven segment display: X
External reset button: X
Using a potentiometer: X
If you have finalized your setup you can continue
Step 3: Designing the Enclosure
I used the tutorial for another puzzle box I mentioned in the previous step as a template to base my design off of. I added holes where I needed them for my components as well as some engraving to help to solve the puzzle. Feel free to use this as template as well, do keep in mind that you probably need to do some resizing to make sure all your components fit and keep in mind the thickness of your material.
Make sure to measure how big your enclosure needs to be to avoid having it too small.
I designed an external reset button in my enclosure because you will not be able to reach the one on your board when it is closed. I reccomend doing that or putting an on and off switch somewhere.
Step 4: Coding With ArduinoADE
I attached my code for this project, feel free to use it as reference if you can make any sense of it. I am fairly new to programming so it is not the most efficient code out there.
After the setup I left the void loop () empty and wrote different functions for the sides of my box. After I was done I called those functions in the void loop () so it was more managable. This way you can easily remove or change the order in which your arduino will process things.
I also added a random component in my box in the setup, here is a tutorial how you would go about that: X
If you are completely done with this step it is time to lasercut your enclosure.
Step 5: Assembly
Assembly is by far the hardest part of a project like this, especially because you need to avoid short circuting your components. I reccomend soldering everything in place, and assembling the arduino part and testing it before putting it inside of your enclosure. After you have soldered everything toghether you can use hot glue to isolate all your bare metal parts. There are neater ways to do this, but I chose this one as you will not see the insides anyway.
After a final test to see if everything was stil working I started puting the leds and the other components into their respective holes. I started at the bottom pannel and worked my way up. I used foam to keep the components in place, I hotglued it to the back of the pannels. You can press the buttons now without them popping back inside - neat!
I kept two pannels lose to be able to adjust things on the inside if I needed to, this is of course completely up to you. This was a playtest prototype so that is why I kept it like this.
Step 6: Final Product
These are some pictures and clips of my final product.