Intro: Flat Pack Tic-Tac-ToeBot
I decided to build this for my son mostly because I wanted to challenge myself and make him something fun, but also because I had left over components after a 3D printer build.
How this works is the player will pick a square for the first move and then the computer will makes its selection. The 2 stepper motors in the X and Y directions will move the play surface and head to the button it chose and fire the solenoid to press the button.
It is a true collapsible, flat pack, CNC, portable, game machine. You can also reprogram this machine to be a lights out game, an easier version of battleship, and so on. I have attached all of the drawings in PDF format for every piece as well as BOM of the components and Arduino program. If anyone has any questions or comments please let me know.
Step 1: Play Surface
The housing is made from Aspen pine. The main reasons I chose this material are how easy it is to machine and that it was only $8 at Lowes for a 12" X 48" board. I will also machine the play surface support out of this stuff as well as some brackets and braces.
I used a CNC router to hollow out the top and bottom as well as to drill the holes, but you honestly could do this by hand pretty easily. If you are going to machine by hand I would suggest using 1" x 12" boards and cutting the 4 sides, then using a router to slot down the middle of each. You can then insert a 1/4" plywood board. Much like making a drawer. In retrospect I wish I would have done it that way. It took about an hour just to mill out the cavities. Aspen doesn't mill very well due to how soft it is.
I ended up staining it with Minwax Jacobean wood finish and really liked the result.
The play top is made from 1/8" black acrylic. The upside of black acrylic is that it looks fantastic when clean but it collects dust like crazy. The other big benefit and reason as to why I chose black is that it's completely opaque at 1/8" thick. I wanted the LED's in the play surface to be hidden until they light up. That's why I machined the .070" deep pockets (it has to be pretty thin to let light through). Each play square will have 4 RGB LEDs that will illuminate blue for player 1, red for the computer, and green flashes will indicate a winning orientation. The hole in the center of each play square is for the push button. I originally wanted to have the buttons hidden under the surface as well and use capacitive touch but the proximity to the other squares and the tendency for your fingers to brush too close to the wrong square made it impractical.
If you don't have a CNC router you can machine this by hand pretty easy. Mark all of the LED hole locations and use a block as a depth gauge to drill out the 5mm pockets. Use a circular saw or table saw to cut out the outside profile and file the corners by hand. Acrylic is easily machinable.
In order to enclose the wiring you do in the next step you'll need a base. I made one by cutting a slightly larger piece of 3/4" thick Aspen Pine (10.125" X 10.125") and hollowing out a 1/8" deep pocket for the circuits and wires to sit. I hollowed it out using a 1/2" diameter router bit and clamping boards to the table to limit travel. Worked great for me. I could have also written a CNC router program but it wasn't necessary.
After installing the 9 push buttons you can lay the play top inside of the housing. If the acrylic doesn't quite fit into the housing it's easiest to just file down the outside edges of the acrylic until it does. When the housing has been stained and finished and the acrylic is clean go ahead and glue down the play top inside of the housing.
Step 2: Game Board Wiring
Insert the 36 common anode RGB LEDs into the holes until they make contact with the acrylic bed. If the holes are oversized you can put a dab of hot glue over the LED to hold it in place. Connect the anode, red, blue, and green terminals together of the 4 LEDs at each play square. We're going to wire the 4 LEDs in parallel to the shift register outputs. The common anode terminals can be connected across all 9 play squares to 1 small perfboard. The play surface assembly will eventually include a ribbon cable with 5V+, GND, DATA, CLOCK, LATCH, 5V+ BUTTON & SIGNAL connections.
Shift Register & Perfboards
Solder each of the 4 TLC5916 shift registers to it's own perfboard. Solder a 1K OHM resistor to the Rext pin of the register. Each shift register has power in, 2 grounds, data, latch, clock, a single resistor to control sinking current, and 8 controllable outputs. The benefit to using a shift register, and in turn multiple daisy chained shift registers, is that I can control hundreds of LEDs with only 3 pins on an Arduino Uno. They might sound complicated but we'll walk through that eventually.
Each play square of the 9 total will require 3 outputs (RGB) from a shift register. That means 27 total outputs. Thus a total of at least 4 shift registers. The shift registers will be wired per the attached image. The first schematic shown is an example of the first register wired to the first 3 play squares. Since there are 9 led connections and only 8 outputs available on this shift register, the next shift register will handle the blue LED for play square 3.
The much larger schematic shows the wiring for all 4 registers. It may be confusing at first but it's not too difficult. I just hope you enjoy soldering! As you can see from the rats nest of wires that emerged that I'm not the best at layouts but I also didn't have a ton of this gage hookup wire available. I used dupont jumpers to do a lot of it.
The push buttons can be handled a number of ways. One method is to purchase an input shift register and wire it much the same way as the LED shift registers or wire each button back to Arduino inputs. A simpler way is to use voltage drops across resistors. In the attached button schematic you can see that there is a 100 Ohm resistor between each button. This means that if I hit the 9th button the voltage is going to drop across 8 100 Ohm resistors before the voltage is read by the Arduino. Inversely the voltage doesn't drop at all if I hit the 1st button.
Step 3: Assembling the Game Board
After testing to make sure all of the LED's and buttons work with the included program, sandwich the upper and lower pieces together and clamp them so the lower board overhangs the upper board slightly. This give you some material to shave off in order to get them flush.
Use 1 or 1.25" long screws to hold the bottom to the top half and then sand or plane the edges to get them smooth. Stain as desired. I am going with a somewhat rustic look with a dark stair on pine.
Step 4: Building the Lower Half (Part 1)
Start by cutting the the 3 boards that make up the frame (1001, 1002, and 1003). As stated previously all the drawings are available for download. I personally cut these pieces using a table saw, router, and hand tools like chisels and rasps to get the small cutouts. You could use a CNC router if you have one.
How you attach the 1001 and 1003 side panels to the front 1002 panel is up to you but I chose to use pocket holes with a Kreg jig. After attaching the 3 pieces together I lightly sanded to get everything level and square and then cut the 1010 base panel. I used luan plywood just because I had it. Shave the edges of the panel to fit snugly inside the grooves of the 1001, 1002, and 1003 frame assembly and fasten with wood glue and brad nails.
Fill the nail holes and gaps with wood filler and sand after it dries. If you want to stain the box, now is a good time to do this assembly.
Step 5: Building the Lower Half (Part 2)
The next step is to add the support braces and the drawer slides for the Y axis. The bottom of the drawer slides needed to be approximately 3/4" off of the base and 1/2" away from the front panel. I used a couple of wood spacers on the left and right drawer slides to position them properly.
The 2 long 1019 support braces are attached to the 1010 base with wood glue. I used a number of heavy weights and paint cans to hold the braces flat against the base on top of a flat surface and waiting for it to dry. The intent of this is to keep the 1010 base form flexing in or out, which would cause the case to close improperly. Each brace should be at least 1.5" from the outside walls.
Now install the 2 hinges onto the lower assembly uprights. Half of the hing is on the uprights and the other half is on the inside edge of the lower assembly.
Sorry about the level of dust in the pictures. After staining the surface is still a little oily for awhile and attracts EVERYTHING. In the end I'll be cleaning the entire assembly and putting on a coat of urethane to protect it.
Step 6: Assembling the Upper Half (Part 1)
The upper gantry is assembled similar to the lower half. The 1004 left gantry panel and the 1005 right gantry panel are attached to the 1006 top gantry panel with pocket hole screws. Before tightening completely, install the 1010 gantry panel and the 2 X-axis rods into their respective positions. Make sure the LM6LUU linear bearings are on the shafts before you assemble them.
The next step is to install the 1007 rear gantry support, but before you do that it's much easier if you install the stepper motor, idler, and belt onto this board first. I did it after the face and it made it kind of a pain. I used an open ended strip of GT2 timing belt and 20 tooth GT2 pulleys. I wrapped the belt around the motor pulley and the idler pully and pulled tight while I clamped it with a pair of clamping pliers. I then used a belt clamp from OpenBuilds to secure the belt in position. If you have some patience, unlike me, you could build this assembly and then measure the distance around the 2 pulleys. You could then by a continues belt to the right length and use a belt tension spring. That's the "right" way to do this.
If you choose to install the LCD then pick a place you want to install it and draw the outline in pencil or wax marker. Drill out the corners and then use a small back cut saw or pull saw to cut the shape out. Keep test fitting the LCD until you get it right.
After the upper assembly is together you can either stain it now or later. Like I had mentioned previously it's much easier and cleaner to stain these parts before assembly.
Step 7: Assembling the Upper and Lower
In order to attach the lower half to the upper half you'll need to make a small block that lines up with the hinge and then attaches to the upper gantry panels. That block is part number 1018. I made mine by tracing the design onto a piece of 1/2" thick pine and then used a scroll saw to cut it out.
Attaching the Hinge Support
Place the upper gantry assembly onto the lower assembly and position it as if the finished box were closed. Use some clamps or weights to hold the two halves in position while you place the hinge supports in the ideal place. Move the hinge into a 90 degree angle from the already fixed side of the hinge and line up the 1018 hinge support. Mark the hole positions and pre drill them. Attach the hinge with small wood screws.
Attaching Upper Assembly
After both hinge supports are attached to the hinges then clamp the hinge support against the side panels as show. This makes sure everything is lined up. Use brad nails and wood glue to attach the hinge supports to the gantry panels.
Step 8: Making the Lids
The height of the lid is up to you but I prefer to make mine as short as possible to make this thing more compact. A 1.5" height is perfect. The bump on one of the panels of each lid is to brace the gantry when it's in the upright position.
The side panels can be attached to each other with pocket holes and brad nails. The cover panel will give most of the stability. That can also be attached with brad nails and of course wood glue.
The best way to attach the lids to the upper and lower assembly is to place the lids on the machine with the bumps towards the middle and clamp them in place. The hinges can then be mounted on the appropriate sides. Use the drawings for reference. Once the lids are attached I used a disk sander to clean up any mismatches between the lid and the lower panels.
The only other piece of hardware I attached is a latch to hold the lids down simply because I had some available.
Step 9: Stepper Motors
The X axis stepper motor, if not already done, can be screwed into the gantry rear support. While you install the stepper motor slide the 20 tooth pulley onto the shaft and tighten in place. Cut off a 1 inch piece of a 5mm shaft and slide it into the hole on the right end of the rear gantry support. As you pass it through put the 20 tooth idler pulley on the shaft and then push the shaft all of the way in. if the shaft is loose put a small dab of wood or super glue on it.
The belt will be trickier if done while the rear gantry support is already screwed into place. Wrap the belt around the idler and the motor pulley and pull snug. Use some sort of clamping pliers to hold the belt while you install a belt clamp.
The stepper motor mount for the Y axis stepper can be placed anywhere towards the middle of the machine towards the back end. Make sure that the game surface will slide the entire way out without making contact. Use wood glue and a couple of countersink screws from the bottom of the machine to secure it in place. The idler pulley for the Y axis is a little trickier. You'll need to use a 5 mm shaft to support the pulley and find a reasonable way to secure that shaft under the game surface. I glued an extra support brace on the base because I didn't have a long enough 5mm shaft to span the entire gap. I used a Dremel to cut a small notch on each end that the shaft could slip in to. I then cut a couple of covers that would go over the shaft to hold it in place. The belt for this axis is created the same way. Wrap the belt around both pulleys and clamp tight with a pair of pliers. Use another set of pliers to pinch on a belt clamp.
Step 10: Electronics
The entire machine is controlled by an Arduino Uno. I absolutely maxed out the digital inputs/outputs so I would suggest using an Arduino Mega if you want to add more features.
The LCD is a standard 4X20 I2C panel with 4 connections. They are +5V VCC, GND, SDA, and SCL. SDA goes to A4 and SCL goes to A5.
I used a small 12V power supply with a 2 amp max. I would suggest a slightly higher amperage supply if you have one. The 12V line is also split off the a buck converter which drops it to 5V to power the arduino and other circuitry.
As mentioned previously the buttons use a 5V power in, a GND out, and a SIGNAL line. The SIGNAL goes to A0.
The shift registers for the LEDs use a +5V IN, GND, DATA, CLOCK, and LATCH line. The DATA goes to D11. CLOCK goes to D13, and LATCH goes to D8.
The stepper motors are drive by 2 Pololu A4988 stepper motor drivers. See the attached schematic for reference. The ENABLE pin is optional but I recommend that you use it. When the ENABLE is pulled HIGH the motor is shut off and doesn't draw any current. It also keeps the motors quiet while not in use. Another way to keep the motors quite is to use microstepping. If you leave MS1, MS2, and MS3 open the motor will take 200 steps to do one revolution. If you tie MS1, MS2, and MS3 together and pull it HIGH to 5V then the motor will do 1/16th microstepping. It will take the motor 3200 steps per revolution.
For the X axis the ENABLE should be tied to D9, STEP to D2, and DIR to D3. For the Y axis the ENABLE should go to D12, STEP to D4, and DIR to D5.
The solenoid is powered by a MOSFET due to the high current draw that would kill the Arduino. I used a IRF3205 MOSFET. The GATE is connected to D10, the DRAIN is connected to ground, and the SOURCE is connected to one end of the solenoid. The other end of the solenoid goes to +12V.
Step 11: Enjoy!
If everything goes as it should you're ready to play. Right now the program works on a random basis for the computer but with a little work it can be set up as a smart AI. Since my son is young I didn't want to make it too difficult of a game for him.
If you have any issues with the built PLEASE get in touch with me. I'd love to troubleshoot with you.
Runner Up in the
Robotics Contest 2016