My Twist On The Twister Game

Photo of talofer99

Made by talofer99

About the project

uno, mpr121, addressable led and Serial mp3 player and some aluminum foil

Project info

Difficulty: Easy

Platforms: ArduinoNeoPixel

Estimated time: 2 hours

License: MIT license (MIT)

Items used in this project

Hardware components

Pimoroni Micro Dot pHAT w/Red LEDs Pimoroni Micro Dot pHAT w/Red LEDs x 1
ESP8266 Serial WIFI Module ESP8266 Serial WIFI Module x 1
Ultrasonic Sensor Hc-sr04 Ultrasonic Sensor Hc-sr04 x 1
Arduino MKRFOX 1200 Arduino MKRFOX 1200 x 1

Software apps and online services

Solder Wire, Lead Free Solder Wire, Lead Free
Arduino IDE Arduino IDE

Hand tools and fabrication machines

Soldering iron (generic) Soldering iron (generic) x 1

Story

Kesem, My 4yr old son is home for over a month now due to the corona virus out there. I was looking for more ways to keep him active and entertained at the same time.

I started with one LED and 6 panels that were connected to an MPR121

If you never used one before, I got a great video for that

The code is pretty straight forward.To communicate with the mp3 I use software serial on pins 8 and 9. This module is really easy to use and theaudio feedback is a great add on to the game.

I use the FastLED library for the addressables. And the bare conductive library for the MPR121.

Each time a game starts a random color is selected, and shown on the LED.

void setSystemState(byte newState) {
 //set newState
 systemState = newState;
 switch (newState) {
   case SYS_STATE_START:
     currentColorIndex = 0;
     currentColor[currentColorIndex] = getRandomColor(99);
     Serial.println(currentColor[currentColorIndex]);
     leds[currentColorIndex] = colour[currentColor[currentColorIndex]];
     for (byte i = 1; i < NUM_LEDS; i++)
       leds[i] = CRGB::Black;
     FastLED.show();
     break;
   case SYS_STATE_WIN:
     serialmp3_play(5);
     blinkSuccess();
     setSystemState(0);
     Serial.println("system state  - success");
     break;
   case SYS_STATE_FAIL:
     serialmp3_play(6);
     blinkFail();
     setSystemState(0);
     Serial.println("system state  - fail");
     break;
 } //end switch
}

If the correct pad is touched another color is added and shown.

If a wrong pad is touched or a pad is left – it’s fail

And when all 4 are touched correctly – it’s a win

if (MPR121.touchStatusChanged() && systemState == 0) {
   MPR121.updateTouchData();
   for (int i = 0; i < NUM_BUTTONS; i++) {
     if (MPR121.isNewTouch(i)) {
       if (buttonColor[i] == currentColor[currentColorIndex]) {
         addColor();
         break;
       }
       else
       {
         setSystemState(SYS_STATE_FAIL);
         break;
       } //end if
     } else if (MPR121.isNewRelease(i)) {
       for (byte z = 0; z < currentColorIndex; z++) {
         if (currentColor[z] == buttonColor[i]) {
           setSystemState(SYS_STATE_FAIL);
           break;
         } //end if
       } //end for
     } //end if
   } //end for
 } //end if

When I started the project what I had in mind was creating a big Simone like game, with more than just 4 colors and spread across the room – so I can have Kesem run around. The major obstacle was the wiring, and I had no desire to go into wireless. So the next best thing was to create a surface – which is what I ended up doing.

After seeing his Ninja move, I realized I got a better result, one that will help Kesem work on his balance and planning of moves.

I had a few suggestions given, like adding a physical rolling element for the color picking, making it look similar to the Twister game. Also adding hand/foot instructions.And I thought of adding points as well, for success vs fails.

Schematics, diagrams and documents

Fritzign file

Code

BIG_simon.ino

This is the main INO, you will need the seria_mp3.h as well.

serial_mp3.h

Credits

Photo of talofer99

talofer99

Maker @ heart

   

Leave your feedback...