Introduction: Multi-player SIMON

This project was inspired by the CLASSIC Simon game, and by the MODERN app "BeReal".

Inspired by these 2 time-spanning mega trends we have decided to fuse them into a fun, easy 2 player multi-player game that can be played remotely with each other.

Watch the video before you go.

Supplies

2 Adafruit Circuit Playground express with a Wi-fi ESP8266 attached

2 Partner TV remote controllers

1 Computer to load the sketch into the CPX's

A Make.com user

A Blynk user

Step 1: Connect CPX to ESP8266

Connect the CPX's to your Wi-fi ESP8266 boards by following the image above.

Run the sketch attached.

Open the Serial Monitor and type the command : "AT+RST".

Make sure the output is as the image attached (cpx-esp8266 output).

If you get a different output, update your firmware version using the esp8266 guide :

https://www.espressif.com/en/support/download/other-tools

or update the version from this direct link and run the Download Tool:

http://bit.ly/esp-firmware-174


Step 2: Learn the Game

 How to play:

 * When started the CPX will sound a theme and light with white leds.

 * Followed by the first round, blue leds will light up showing you which numbers are in the sequence (number of leds = digit to click).

 * Click the digits in the right order and watch the CPX receive them.

 * The number of digits increase each round by 1 and the sequence is generated randomly.

 * Your score will be composed of the last level you passed, and the time it took you. Better level will always win, and in case of a tie, best time will prevail.

 * You shall pass 10 rounds to win the game!

Step 3: Creating the Sketch

Download the attached file sketch "final_project.ino" into your computer.

Inside the sketch - edit the wi-fi information: network name and password.

Step 4: Creating Blynk Template and Devices

Templates (inspect image "templates")

The template is based on five virtual pins that maintain the interface between the board and "make" site as follows:

1. V0 - Starter in - receives the value 1 via an http request from "make" website, which update it when a "starter scenario" is activated by the opposing player. The CPX reads the V0 data while the game is not active, and starts the game when it detects an update of the pin data.

2. V1- Score - receives integer data from the CPX about the score of the last game played. The pin is connected to a webhook on "make" website which triggers the "Main scenario" sequence of events as described below. The pin receives values ​​between 100,000 and 210,999 which "make" processes into data about the game played (player name, stage and game time).

3. V2 - Starter - receives data from the CPX, after pressing the right button. When the user presses the right button on the CPX, the pin will change its value from "1" to "0" and vice versa. The pin is connected to a webhook on "make" website which activates the sequence of events for the "Starter scenario" as described below, at the end of which the value of the V0 pin changes on the opposing player's device.

4. V3 - Scream - After breaking a record, the user is required to scream with joy for 5 seconds. The strongest measurement of the cheers is sent as an integer data to pin V3, which is updated accordingly. The pin is webhooked to "make" site, which triggers the "Send scream scenarios".

5. V4 - High Score - After each game, the "Main scenario" is activated on "make" site. If a new record is broken, the scenario will update V4 via an http request (receiving the value 1). The CPX, which has just finished a game, reads the data of V4, and if it detects a change, it will trigger the sequence of events in the code that will start the recording of the scream, and the lighting of the board.


Devices (inspect image "Devices")

On "Blynk" website, we will create two devices based on the same template as described in the previous section. Each device receives data from a different user's board, and transmits its data through different webhooks to run scenarios on "make" website.


Webhooks (inspect image "Webhooks")

The webhooks are divided into three groups with different roles, where in each group there are two links to pins that are identical in number, but different in device:

  1. "Game Starters" - are connected to V2 each on their device, and start the process of "Starter scenarios" on the opponent's CPX using "make" site.
  2. "Score senders" - are connected to V1 on their device, and starts the "Main scenario" process by sending the result data to "make" website.
  3. "Scream senders" - are connected to V3 on their device, and starts the process of "Send scream scenario" by sending the input data from the scream to "make" website.


Dashboard (inspect image "Dashboard")

The dashboard view reflects the user status of each pin in the device, and what values ​​it is receiving and transmitting. The display of all pins except V0 is "label" display, a "string" data of the current value in the pin. We present V0 as a switch that enables us to distinguish easily if a change was made as a result of pressing the right button on the opponent's CPX.

Step 5: Creating Make.com Scenarios

Main scenario:

  1. Webhook trigger - new score arrived in Virtual pin V1 of one of the CPX's.
  2. Google sheets - get cell H1 - current highscore.
  3. Google sheets - add a row. Coding the score as follows:
  4. each score is a number in range 100,000-220,000
  5. left-most digit represents the player that posted the score - 1 / 2 accordingly.
  6. tens of thousands (0-10) represent the level reached.
  7. hundreds (0-999) represent time in seconds.
  8. decoding the score is processed in this make.com scenario, so in the scoreboard only the processed date is posted. the lower the score, the better it is.
  9. Google sheets - update cell K1 - latest score posted.
  10. Google sheets - update cell F1 - player number that posted that score.
  11. Google sheets - get cell K1.
  12. Google sheets - get cell F1.
  13. Router - reached if and only if highscore is broken. This is done with a filter before the router with the condition: K1 > H1. The router navigates the flow to the right sequence of modules according to the player that posted the new highscore. Each time, only one of the paths will be active since only one player can break the record at a time. Deciding to which path will continue the flow is done by 2 filters positioned after the routed checking the value of F1. If F1 is player 1, the bottom path (modules 9-11), else the higher path (modules 12-14) will be active.
  14. HTTP request - update Virtual Pin V4 (highscore) in CPX 1 to value 1 representing player 1 broke the highscore.
  15. HTTP request - update Virtual Pin V4 (highscore) in CPX 2 to value 1 representing player 1 broke the highscore.
  16. Telegram -
  17. set up a telegram bot (here's a link to a specific great tutorial)
  18. create a telegram channel and subscribe to it from both players, and from the bot.
  19. the module sends a message to the channel "Player 1 broke the record. He reached level x in y seconds. Time to shout!"
  20. HTTP request - update Virtual Pin V4 (highscore) in CPX 1 to value 2 representing player 2 broke the highscore.
  21. HTTP request - update Virtual Pin V4 (highscore) in CPX 2 to value 2 representing player 2 broke the highscore.
  22. Telegram - same setup as module 11 - sends a message to the channel "Player 2 broke the record. He reached level x in y seconds. Time to shout!"


Starter scenarios:

  1. Webhook - Virtual pin V1 (activate opponent) value updated in CPX 1.
  2. HTTP request - update Virtual pin V0 (start game) in CPX 2.
  3. Webhook - Virtual pin V1 (activate opponent) value updated in CPX 2.
  4. HTTP request - update Virtual pin V0 (start game) in CPX 1.


Send scream scenarios:

  1. Webhook - Virtual pin V3 (volume) value updated in CPX 1.
  2. Telegram - send message with max volume detected.
  3. Webhook - Virtual pin V3 (volume) value updated in CPX 2.
  4. Telegram - send message with max volume detected.

Step 6: Getting to Know the Scoreboard

Link to the Google Sheets file. Clone the file.

Now update all the Make.com scenarios you created: update the Google sheets modules to operate on the file you have created.

Step 7: Update Sketches Accordingly

Update the sketches:

  1. insert the blynk tokens according to the tokens provided by the blynk app.
  2. update the send score function:
  3. player 1 sends {score + 100,000}
  4. player 2 sends {score + 200,000}
  5. BLYNK_WRITE(V4) function -> if condition:
  6. player 1 : if (high_score_broken == 1)
  7. player 2 : if (high_score_broken == 2)

Step 8: Play, Win, and SHOUT LOUDEST!

Load the sketches to the CPX's, and run the make.com scenarios.

Now each player can challenge the other by clicking the left button, activating their CPX with the game.

Challenge each other once a day, and try to break each other's records.

Have fun!