Frand's Mind Bender (Part 1) if you are just joining us. In the last post, I describe the origins of the puzzle as well as how I ended up with the components I used to build it.
I ordered the display I selected and it arrived a few days later. Now that I had all the components that I needed, I actually needed to figure out how I was going to implement these special knobs that one could push, pull, twist left, and twist right.
Unfortunately, these knobs were not the type you could purchase at an electronics store, though I did look around a bit. These were not typical knobs: I needed them to spring back to position after you twisted them, more like a jog wheel on an old school blackberry than a dial than a volume dial on a stereo or something.
The blocks were pretty tricky to make: I had a friend Patrick Sheehan who is a carpenter help me out a bit with these, since I wasn't quite sure how to go about it.
I brought my measurements over and he had a piece of stock that was the right width and height already (I think .75x.75). Using a dado, he cut a groove down the center of the stock. Next, he turned the stock 90 degrees and used the dado to cut a perpendicular groove. Finally, he cut the finished block off using a chop saw.
This probably would have taken me an hour and several fingers to figure out, but he was done in about 5 minutes. All I had to do next was drill a vertical hole and a horizontal hole, and the blocks were completed.
I wasn't quite sure how I was going to attach the switches to the block, since they don't really have any type of mounting hardware. I ended up using a jigsaw to cut out small pieces of circuit board. Then I screwed the circuit board to the blocks and soldered the switch to the circuit board. Fortunately, there isn't much stress on the solder in this position, so it is quite sturdy.
One thing that was a huge pain in the butt was that the holes on the circuit board weren't quite big enough for the screws I had, so I had to pre-drill all these holes. That's 2 holes per board, 4 boards per block, 4 blocks in the puzzle for a total of 32 holes, which took a while.
I connected the switch matrix up to the display, and wired the display to the microcontroller, and amazingly it all worked! Now the last step was to get the microcontroller off of the development board and on to its carrier board that would fit into the box. You can buy a carrier board, but they didn't have quite what I was looking for. Instead, I decided to build my own.
Now that I had my components working, I just needed to put them in a box! Since I had just finished building a my first puzzle box, I was pretty confident in my ability to do this. The one tricky thing was determining how I was going to mount the switch blocks. If I mounted them permanently, it would be quite difficult to repair something if a connection broke.
Instead, I decided to glue them to pieces of plywood, and then screw these pieces of plywood to the base of my box (see photo above). This provided two benefits: I could remove a faulty switch and if the hole for the dowel on the front of the box didn't line up exactly with the hole in the block, the block would pivot slightly to line up.
It was tough to get the hole for the display the correct size. I traced around the outside of it, but was very careful not to cut the hole too big, since that would be unsightly. Instead, I ended up cutting it too small and spending almost an hour sanding it with a file until it was large enough. One of those tiny vibrating sanders would have come in handy, I think.
I mounted all the components inside the box, and everything worked great! It was really fun being able to step work through the puzzle, just like I did in when I was playing with it online, except I had actual knobs! Ok, that may sound lame but it was very exciting.
The program that I wrote for the microcontroller was kind of interesting. There are a number of words that are stored in memory that make up the puzzle. Since the maximum length of these words is 14, the typical way to store them is to give each word a 14 byte chunk of space, and then you can find the location of the nth word by taking the location of the first word and adding (n-1)*14 to that location. Then you just read off the characters until you arrive at a null character, and you're done.
This would be fine, but I was trying to conserve space since a Basic Stamp has fairly limited storage space and I needed the extra space for instructions on the objective of the puzzle and the congratulations messages that are shown after you solve the puzzle. With that simple storage method, there is a lot of wasted space because most words are much less that 14 characters long.
What I ended up doing was storing the length of the word right before the word, so I could loop through the array of words until I arrived at the one that I wanted. For example, say I wanted the 4th word in a list containing "one", "two", "three", and "four". This list would be stored as "3one3two5three4four". I start off at the first location, read the first 3 then skip 3+1 memory locations ahead. I read the next 3, skip 3+1 memory locations ahead to the 5. I read the 5 then skip 5+1 memory locations ahead. Now I am on my 4th cycle through the algorithm and am seeking the 4th word, so I should be pointing the location right before where the fourth word starts. Bingo!
If that made no sense and was not at all interesting, I apologize, but I hope that those of you who have done some programming think that it is kind of cool. Basically I implemented a rudimentary linked list data structure where each element pointed to the next element. Of course, the Basic Stamp language doesn't allow me to do any object oriented abstraction, but it did save me some space versus simple array lookups.
To this date, nobody has solved this puzzle in its physical incarnation (other than me), which is somewhat unfortunate. I think a puzzle that nobody has had the joy of solving is kind of like a kite that has never flown: it hasn't reached its potential yet! I loaned it to David from Eureka Puzzles for a while, but he didn't have the time to solve it. I might consider loaning it out if you would like to give it a shot! Perhaps a temporary trade for a puzzle I'd like to try.
Graduating from the New Old School
1 day ago