Introduction: Interactive Twister

Twister is a classic family game and I'm sure that everyone who reads this Instructable has at least played it once. The main goal of the game is to be the last man standing on the canvas and make sure you don't fall over while performing the tasks chosen by the spinning wheel.

The problem is with every game of Twister, there always has to be someone who spins the wheel. Wouldn't it be a lot easier if all of this could happen automatically? That way everyone can have fun while playing a game of Twister.

I'm a student of NMCT at Howest Kortrijk. This is or final project in our first year.

In this Instructable i'm going to explain how I made an interactive Twister game and how you could build it at home.

Step 1: Requirements

  • Raspberry Pi
  • T-cobbler
  • Twister game
  • Stepper motor
  • DRV8825
  • LDR
  • Capacitators (100 µf and 10 µf)
  • Cables in different colours
  • Aluminium foil
  • Ductape
  • Electrical tape
  • Double-sided tape
  • Velcro
  • Wooden planks
  • Breadbord
  • Perfboard (optional)
  • Female headers(optional)
  • 5V adapter for Raspberry Pi
  • 12V adapter
  • 2 x MCP23017

Step 2: The Twister Mat

Requirements:

  • Roll of foam
  • Twister mat
  • Ductape
  • Aluminium foil
  • cables
  • marker

Instructions:

Making the mat is actually the most work of the entire project. It's not that hard to assemble but you just have to repeat everything 24 times. It also involves a lot of ductape... and I really mean a lot.

To start you have to cut 2 pieces of foam that are the same size as the Twister mat. I used foam thats used to put under parquet floors. The problem with that is that the foam is quite thin. If you can find foam thats at least 2mm, that would be a lot better and you'll have less work to make the canvas but i'll get back on that later.

On the first layer of the foam you have to put four stripes of aluminium foil across the entirity of the foam. These will be used as ground for the circuit. The best way to attach it is to put ductape over the sides.

Put the next layer of foam on top of the Twister mat. Draw a circle for every dot on the Twister mat. you have to cut a hole in every circle on the foam. The diameter of the hole isn't that important, just make sure it isn't too big or to small.

Every hole needs to be covered by aluminium foil. Again the best way to attach it is ductape. Make sure that no patches conduct to avoid faults.

This isn't necessary but if the used foam is less then 2mm, you have to put some kind of heightening on each hole to prevent the foil from sticking together. I used little foam peanuts that came with the packaging of my components.

The last step is the cabling. Every patch needs 1 cable. The ground patches can be connected to eachother and later with the Raspberry pi.

Step 3: The Housing

Requirements

  • wooden planks
  • nails
  • drill
  • velcro

Instructions:

dimensions: 32cm x 30 cm x 8cm

The housing is just a simple box-design. You can see the planks you need in one of the pictures above. The wood was sawed in my local home depot. I'm not that handy and for a small price they saw the wood and you already know that it's going to be the right dimensions.

To assemble the box I just drilled the screws on the bottom. The length of the screws isn't that important. Just make sure they are longer then the height of the ground plate and that they are not too long so that they would break the wood.

In the middle of the cover you have to drill a small hole to fit the motor. That hole needs to be 5mm in diameter.

The cover is attached to the box using velcro.

The last thing you need to do is make a hole in the front for the cables of the Twister mat and a hole in the back for the two adapters. The diameter of the holes depends on the adapters that you use and how you can manage the cables of your mat. I cut a rectangular hole for the mat cables because I didn't have a drill that was large enough.

Step 4: Electronics

Requirements:

  • DRV8825
  • Stepper motor
  • 2 x mcp23017
  • LDR
  • 100 µF electrolytic capacitor
  • 10 µF electrolytic capacitor
  • Raspberry Pi T-cobbler
  • 24 x 330 ohm resistor

Instructions:

The fastest way to make all the electronics is to put it on a breadboard. The problem is that nothing is fixed and and some components can come loose. The best way to go is soldering everything on a pcb. I soldered the stepper motor driver and the sensor. I left the two IO expanders on the breadboard because a lot of cables go to the MCP23017's. How you do this is entirely up to you.

Some sidenotes on the wiring:

The stepper motor has two coil pairs. The wires from the pairs on my motor where:

black,green -> pair 1

red, blue -> pair 2

Make sure the inputs from the Twister mat are connected in the right order. The first dot is connected to GPA0 of the first MCP23017. The last dot is connected to GPA7 of the second MCP23017. Make sure there is a resistor at the end of every input.

Step 5: Raspberry PI Setup

Requirements:

  • Raspberry PI
  • SD-card
  • Ethernet cable

Instructions:

Download the Raspian image from https://www.raspberrypi.org/downloads/raspbian/. Make sure you download the desktop version. Burn the image on your SD-card using a burning program. I used etcher, but feel free to use another program. Before you put the SD-card in your Pi, you have to change some things with the pc. Open the boot segement of the SD-card. You can't open the other segement because Windows doesn't recognize Linux. In the boot, open the file: "cmdline.txt". At the end of the file, add the line: "ip=169.2554.10.1". This is an APIPA address and is used to connect the pc and the Pi over ssh. Once that is done, create a file on the boot segment thats called "ssh" but without an extension. That way the Pi will enable ssh on boot.

Connect your Pi to your pc with an ethernet cable. You will need to download a program to ssh to the Pi. I used putty. Open putty and fill in the APIPA address(169.254.10.1) and open the connection. When the PI first boots up, it may take a while before everything is ready. Just wait a moment and try again later if you can't connect. Once you can connect, login with the standard credentials: username: pi, password: raspberry.

If you want you can make your own user. Now you need to set up an internet connection. If you want to use wifi, you can use these two commands:

wpa_passphrase 'SSID' 'Password' | sudo tee -a /etc/wpa_supplicant/wpa_supplicant.conf
wpa_cli -i wlan0 reconfigure

Install these programs using the following commands:

sudo apt update && sudo apt install -y python3-venv
python3 -m pip install --upgrade pip setuptools wheel <br>python3 -m venv --system-site-packages env
python -m pip install mysql-connector-python argon2-cffi Flask Flask-HTTPAuth Flask-MySQL mysql-connector-python passlib flask-socketio

Step 6: Database

Requirements:

  • Raspberry Pi
  • Ethernet-cable

The application uses a database to store information about the users, the winners and the game data.

First set up the db program on your Raspberry Pi. You already installed Mysql on the Pi in the previous step.

Use "sudo systemctl status mysql" to test if Mysql is working.

Start Mysql:

sudo mariadb

Then enter the following code:

CREATE USER 'project_name-admin'@'localhost' IDENTIFIED BY 'adminpassword';
CREATE DATABASE project_name;
GRANT ALL PRIVILEGES ON project_name.* to 'project1-admin'@'localhost' WITH GRANT OPTION; 
FLUSH PRIVILEGES;

Change the name of the project as you like.

To fill the database, run the sql file that is given with the code later on in this instructable.

Step 7: Code

You can find the code on the following link: https://github.com/TiboVanHoutte/Twister-TiboVanHoutte

Just clone the repository onto your Raspberry Pi.

Make sure it's cloned in the direct directory under your user.

Step 8: Automated Service

The program has to start when you Raspberry Pi boots up. In order to do that you have to make a service of your application.

The configuration is already made and is located in the conf directory.

The only thing you have to do to let the service start on boot is this line of code:

sudo systemctl enable project1.service

The only problem is that the pi will wait for a network to boot. You can disable this but it doesn't have any effect because we use the APIPA address in the cmdline.txt. If you want him to boot faster, you have to remove the APIPA address but then you'll need to hook your Pi up to a monitor when you can't connect to wifi if there is a problem.

Step 9: Instructions

Type the ip-address of th Pi in your browser. Don't forget to add :5000 to the ip-address.

When you arrive at the site, just start a new game and fill in the player names.

Once the game starts, you have to wait 5 seconds untill the two devices are connected.

To let the pointer spin, cover the light sensor. After the pointer stops spinning, the move appears on the screen.

If someone falls or can't perform their task, they lose and you have to push their name on the screen.

The last player standing wins.

You can see everyone who won in the past in the history chart.

Have fun!