Light Puzzle Box

Welcome! This tutorial explains to you how you can make your very own light puzzle box!

The puzzle in question has no uniform name, but I call it a 'switch puzzle': where a certain amount of switches are used to control a certain amount of lights, with the objective to turn all the lights on by pressing the right combination of switches.

You will learn how to build an arduino that controls this, and how to fit it inside a small box to booth! This tutorial will not explain the code behind it... though I will have a link to my GitHub where you can download it and experiment with it yourself.

Alright, I hope you enjoy, and lets get to it!

Step 1: Materials

1. Arduino Uno Rev 3

2. Protoshield - Uno-Leonardo

3. USB A naar USB B kabel - any meter

4. Rode Drukknop 7mm (6x)

5. Groene LED - 5mm Difuus (5x)

6. 10K ohm resistor (11x)

7. Soldering Equipment

8. Lead Wire

9. Cable

10. Arduino Uno Housing

11. 6 extra resistors (ohm doesn't matter, we need the rods)

12. (Access to a) Power Drill

Step 2: Design Choices: Concept

I'll start of by explaining my design choices, both conceptually, aesthetically and technically.

Let's start with the concept. The project was graded by a combination of the aesthetics and the technicalities. I am pretty abysmal at manual labor, so I wanted to spent more time on the code for this project than on the looks. Funny, because in the end I absolutely think my little box looks great, not artistically perse, but... well we'll get to that later.

As I was saying, I wanted to spent more time on the code, so I quickly came with the concept for a puzzle box. Specifically, a switch puzzle box, because it was easy enough that I wouldn't overwhelm myself, but still had plenty of room left for me to explore. A switch puzzle is one where you have a couple of buttons you need to press in order to turn all the lights on. The trick is that buttons toggle the lights, so if a light is already on, buttons connected to that light will turn it off again. I did some digging and was actually surprised there was no theorem for these puzzles, so I had to come up with my own.

I was banging my head against the wall with trying out different combinations for a while without finding a pattern. Often times I would create puzzles that weren't even solvable. But eventually I found out that if, for example, you have 4 lights with 4 different combinations of light-toggles, you can then create EVERY combination of a 2^4 matrix. That meant that, were you to add a light toggle combination that could already be created with the other buttons, that combination wasn't adding anything to your puzzle. And THAT meant that every combination you purposed to a button had to be unique from what could already be created by the other buttons. I'm getting a bit abstract here... let me try to explain the theorem with an example:

The 2 current button combinations:

(1) 1 - 0 - 0 - 1

(2) 1 - 1 - 0 - 0

Possible combinations (4):
0 - 0 - 0 - 0 (null)

1 - 0 - 0 - 1 (1)

1 - 1 - 0 - 0 (2)

0 - 1 - 0 - 1 (1 + 2)

Combination from combining those buttons:

0 - 1 - 0 - 1 (1 + 2)

Now if we were to add another combination, the possible combinations we would be able to create would scale up to 8. EXCEPT if that combination would be 0 - 1 - 0 - 1!

The 3 current button combinations:
(1) 1 - 0 - 0 - 1

(2) 1 - 1 - 0 - 0

(3) 0 - 1 - 0 - 1

Possible combinations (still 4!!!):

0 - 0 - 0 - 0 (null OR 1 + 2 + 3)

1 - 0 - 0 - 1 (1 OR 2 + 3)

1 - 1 - 0 - 0 (2 OR 1 + 3)

0 - 1 - 0 - 1 (3 OR 1 + 2)

So after a long journey, I finally figured out that, to generate such a puzzle, you needed to keep a list of possible combinations and make it so that those combinations would not be connected to new buttons. That way, my puzzle can always create every combination on a 2^n matrix, and therefor it will always have a solution.

Step 3: Design Choices: Aesthetics

I am not really aesthetically set, so to speak... when someone asks me to draw a spaceship, a draw a triangle that 'represents' a spaceship. That's because I'm practical. And as such, I made design choices about aesthetics based more on practicality than visuals. Hence - it needed to become a small box. That it was gray never formed an issue in my mind.

And I have no doubt it was worth it. It fits neatly in the palm of your hand and you can take it with you on the go, and that was no easy task. I had to do extended research on all my components, to check and test how to reduce my part use and space without sacrificing functionality. It truly was a time-consuming process, with lots of trial-and-error.

But in the end, I think that it made me understand the basics of arduino more thoroughly than most others who went into this project blindly, since I had to learn how each and every electrical connection of my components was created.

Step 4: Design Choices: Technical

My technical choices are not very complex: I figured out what I needed, I bought it, and then I used it. We had to buy all our components ourselves, so I was careful to figure out exactly what I needed before I bought it.

But I CAN tell you that I based my choices on making my box small and with the Arduino Uno as my foundation. Hence why I bought the prototype shield, so I could combine the Arduino and the components into 1 solid block. I also made sure my lights and buttons would be able to stick out of the housing I bought for it, else it would be kind of a crappy design nonetheless.

Unfortunately, I made a mistake when I bought my buttons. Everything about them was right, except... well I'll explain it to you in the next step, and how you can fix it.

Step 5: Fixing Your Buttons

When starting out, you will notice that your buttons have these weird stilts at the ends. Unfortunately, this makes them useless for fitting them into a breadboard.

So what you need to do is solder rods to the ends of all of them. Cut off the ones from the 6 extra resistors you bought, place the button in a grip to keep it straight for you and use a glove or some cloth to hold the rod with while you're soldering. Be careful not to burn the plastic from the buttons.

After that, you have working buttons for use with a breadboard!

Step 6: Preparing the Housing

This part is a lot of drilling, so I hope you have access to those, otherwise I'm afraid you'll need to skip this part.

So the first thing you need to do is to open your housing and flatten out the bumps on the bottom. They ruin your height and if you leave them in, the arduino will be sticking out. Remove the bumps by drilling through them, plain and simple. You will also need to drill a hole on the point where your USB cable will be sticking out. Once it's big enough, use a file to square out the corners, just enough for your cable to fit through. On the top, create 6 6mm holes at the points where your buttons are going to be. Also drill an oval hole for all your LEDs. Use a file to straighten out the edge so it looks a bit better.

Finally, you need to cut off 2 of the edges from your arduino, just a little, so it fits in the box. In the photo if you look closely on the top and bottom right you can see that I've done this because the screw holes are blocking the arduino from completely fitting in.

Step 7: Soldering

Excuse the scale of the buttons in the schematic. They were incorrectly implemented into the program and I couldn't change it.

To save space, we are going to utilize the full functionality of the arduino Shield. If you look at the picture, you will notice several holes that are connected on a single silver line. Those are lines that carry either the ground input or the 5V input by default. We are going to make a lot of our connections to those lines instead of pluging them in directly, since it saves us space.

Let's start with the lights. You need to put a resistor into plugin 2, 3, 4, A2 and A3 and connect them to the plus rod of the LED. First make sure to cut the resistor and the LED rods shorter so they don't take up as much space. Make sure to put the minus rods all on the same row so we can later connect them to the Ground connections as one, saving space.

Once that is done, we are going to connect the resistors for the buttons. One end of them needs to be in the 5V input, the other end will be next to the hole one of the rods of our button is going to be inserted in. It is advised you don't solder these until everything is in place, so you are sure it will fit in the end. You will also need to make sure the resistors aren't blocking any other holes you need, again warning that you shouldn't solder them until everything fits.

Once that's done, insert a cable from one of the following inputs next to your resistors end / the hole one of the rods of your button is going to be inserted in. The inputs are: 9, 10, 11, 12, 13, and A0. (Though if you are going to use my code later on in this tutorial, you need to use input 8 instead of 9, because my own 9 input was broken. You will also have to make sure that your 'last' button is plugged into A0, since that becomes the reset button.)

Now at last, insert your buttons. If everything fits neatly in place, it is time to start soldering. For every button, fit one rod to their respective resistor and cable. The other rod, we are all going to connect to a ground connection. If you look at the picture above, you will notice that one of the solderings is long and thick. That's the one soldering that connects all the buttons to the ground connection.

Step 8: Adding the Code

GitHub Code

Here you can find the code to the project. I have already explained the groundwork's of how I've created it in Design Choices: Conceptual, earlier in this tutorial.

Step 9: Fitting It All Together

Now, all you need to do is screw the lid on top, plug it in, and you have a box that lets you play randomly generated switch puzzles for eternity!

I hope you've enjoyed this tutorial and good luck building your own.



    • Fat Challenge

      Fat Challenge
    • Arduino Contest 2019

      Arduino Contest 2019
    • Pie Contest

      Pie Contest



    4 days ago

    What a cool Instructable! This looks like a fun puzzle!