Software apps and online services
Hand tools and fabrication machines
For our MEGR 3171 IOT project, we decided to create a game with the premise of remote play. This would be impossible with just a single board. We decided to use a game familiar to everyone: Tic-Tac-Toe. Simple right? As it turned out... No.
The premise of this project would be that we would have two tic-tac-toe boards, controlled by switches, that communicated the events going on in the game with different colored LED lights. The lights would inform the user of their turn, the other player's moves, the winner, loser, and if any errors have occurred in the game. Due to the use of two boards with two Particle Photons, two people would be able to play this game in two remote locations as long as a power source and a Wi-Fi connection is present.
Creating the Board
The base for this project is the boards in which the game is played. These boards were cut from a 24" x 48" slab of 1/4" MDF wood. In each of these boards, holes were drilled out for two lights and a switch in each "section" of the tic-tac-toe board. In the top corner, four more holes were drilled in which four more lights would be inserted.
In the section of the board designated for playing the game, switches were inserted into the holes designated for the switches. These switches will be used by the player with the board to make their moves. White lights were inserted to designate the moves made by the opposing player. In the upper corner, a green, red, yellow, and blue light were inserted to designate a win, loss, error, and when the user's turn is happening, respectively. Each component is being held into the board using 2 Part Epoxy, but after a number of switch failures hot glue would probably be a better plan.
On the back of the board, jumper cables and resistors were soldered to each component to create the circuits as seen in the schematic on this page.
Creating the Circuit and Code
While the current state of this project is "in progress", the vast majority of the base algorithms and the plethora of bugs have been worked out. The Particle platform being cloud based creates a set of challenges that can be difficult to overcome with a complex code especially for beginners like us two. The code has gone through many dozen revisions to get where it is now. The boards perform all of the primary functions and utilizes some clever techniques for interfacing with the user and the cloud.
From a hardware perspective, the Photon has pretty limited I/O for a project like this. Ideally, each switch would have a single GPIO pin to activate. However, the Photon doesn't have enough pins to perform both switch recognition as well as LED output for the opponent's positions. Therefore a method was used to reduced required inputs from 9 (one per switch) to just 3 by using a variable voltage divider. From this recognition, the signal can be sent to the other board to light the correct LED. As seen in the schematic, when the player flips a switch, it moves the current in the circuit through different resistors which changes the voltage going into the photon.
Also included in the code is the blue "your turn" light turning on after a signal is sent from the other photon. This proved to be the most difficult aspect of the project. Many limitations and drawbacks of the photon were exposed while trying to make the boards reliably transfer the turns between themselves. This function now carries the position information between the Photons as well. During the two agonizing weeks of debugging lots of another integrated feature, the yellow "error" light , was seen. This LED turns on for various errors such as having switches activated during a game reset or when a solder connection breaks.
The photon can be easily programmed to recognize the different combinations for what produces a win in tic-tac-toe.
When a win is detected, the photon signals the "win" light to activate on its board, and the "lose" light to turn on on the opposing board. This also begins a reset process on both boards where the game is reset after about 20 seconds and ready to play again.
ThingSpeak - https://thingspeak.com/channels/367730
We used ThingSpeak for our cloud data logging feature. The main graph is of the TurnCount variable within the code. This proved to be a valuable debugging tool throughout the development process.