MEGR 3171 Project
For our MEGR 3171 IOT Project, we decided to create a Simon Game on one Internet Button known as Player 1. The Player_1 system will send a signal to the other Internet Button (Player_2) when a round has been started and Player_2 will send an email to an interested party. This way you will know if someone is playing your Simon game. Additionally, Player_1 will publish its wins and losses to Player_2. Player_2 will then send this data on wins, losses, and new rounds to a spreadsheet for further analysis.
Trust the Process
There is a Simon library present in the Particle database. This library works with one Internet Button and generates the pattern for the user to replicate. We have edited the library to fit our project's needs, which is shown in the included codes, labeled Player One SimoN.h code and Player One SimoN.cpp code. These codes are used by Player_1 to complete the game. As Player_1 completes each round, a signal is sent to Player_2 that tells whether or not the code was repeated correctly. This will prevent Player_1 from spreading a little white lie that they are the better Simon player, or even the best Simon player, a title people around the world crave to have. If Player_1 only wants to practice and Player_2 isn't near their photon, they'll still know the result.
In order to optimize the sensors included in the internet button, and to include an indication of Player_2's photon working, the built-in accelerometer is utilized in the Player_2's code. When Player_2's photon is picked up, the accelerometer registers the movement and flashes the LEDs inside the internet button accordingly. This feature can also be used as a means to distinguish Player_1 and Player_2 since Player_1's photon does not utilize the accelerometer.
Using IFTTT
By using IFTTT, the code creates outputs to indicate Player_1's wins or losses of each round. Additionally, it will indicate when a new round begins. The data is compiled into a Google Sheet, which is a free program open to anyone with a Google (Gmail) account. The data in the sheet was then formatted into a graph. You may analyze the data however you wish. An example of this output is shown in the two images below.
It should be noted that up until the first new game (0.5) data point and after the last single win (2) data point, the applet controlling the "new game" data was turned off. In the tabulated data image, this would be row 41 and row 56, respectively. The applet was disabled because it was noticed in earlier data sets that the applets were not posting down to the seconds. Due to this, the Google Sheet could not distinguish between what order the points were supposed to be shown in. This caused all of the new game (0.5) data points to be shown together at the beginning of every minute. This can be easier seen in the second image with the tabulated data. Until IFTTT can begin publishing down to the seconds, it is not very useful to post the new game (0.5) data. The applets did publish the wins (2) and losses (1) in order. It was only the new game (0.5) data that was skewed.
To create this output, you will need to create a new applet inside an IFTTT account. If you do not have an IFTTT account, they are free to create through the IFTTT website. To create the applet, use the following points:
- Choose Particle as your "This" feature
- Select New event published
- Place "SFG" in event name. SFG is the event name in our code, but it may be beneficial to change it to a unique name in your own code.
- Set event content to "1" for a loss
- Change device name to internet button that will be running Player 2 Simon Game code
- Select "Create Trigger"
- You will now edit the "That" portion of the applet
- Search for Google Sheets as the service
- Choose "add row to spreadsheet"
- NOTE: You can change spreadsheet name, but this is optional
- The Drive folder path can be left blank or renamed. This will be the name of the folder that the spreadsheet is published to
- Choose "Create Action"
- Repeat for a win and a new game. Everything is the same except event content is changed to "2" for a win and to "0.5" for a new game. The spreadsheet name and drive folder path must be the same as the first applet so that they publish together.
You can create a graph from the output data if you wish.
In order for the email output to be generated, another IFTTT applet must be created. An example email is shown below. The wording of the email can be changed in your applet.
To create the email output applet, use the following points:
- Choose Particle as the "this" portion of your applet
- Select "new event published"
- Place "GameStart" in event name (this is the event name in our code, but it may be beneficial to change it to a unique name in the code)
- Set event content to "1"
- Change device name to internet button that will be running Player 2 Simon Game code
- Select "Create Trigger"
- You will now edit the "That" portion of the applet
- Select "Gmail" as the service
- Choose "Send an email"
- You can enter as many email addresses (up to 20) to be notified of the start of a new game
- The subject and body categories can be edited however you choose
- Choose "Create action"
Once the applet is functional, an email will be sent to the desired addresses each time the program is ran.
Scroll through the following images to compare your IFTTT applets with ours.
Final Product
In the following video, you can see the photons interacting with one another as the user plays the game. You can also see the different LED displays as the accelerometer is activated.
Comments