Looking for a fun way to learn how to use Raspberry Pi and a variety of Raspberry Pi accessories? In this tutorial, you'll learn how to use a Raspberry Pi, Sense HAT, PIR (motion) sensor, and a Raspberry Pi camera to make a Dance, Dance, Revolution game that automatically uploads a gif of your dance to Twitter.

We created this Raspberry Pi Dance, Dance, Revolution Game at Picademy Jersey City (June 2018). See the final output on Twitter here: https://twitter.com/Picademy_DDR
- The motion sensor detects a new player, which prompts the player(s) to input their name(s) and gives directions for the game.
- The Sense HAT displays “3, 2, 1, GO” and then give the player(s) five random directions to point their arms for the dance
- While the player is dancing, the Raspberry Pi camera captures an image of each dance motion, then stitches these together into an animated gif and posts the final gif of the dance to the Picademy_DDR Twitter account!
If you want to get a little more familiar with all of the Raspberry Pi accessories before starting, you can look through the following tutorials:
Raspberry Pi Camera Sense HAT PIR (motion) sensor
- Raspberry Pi + micro SD card with NOOBS (I used a B+, but you should be able to use any model compatible with the other materials)
- Sense HAT
- Mini black hat hack3r
- Raspberry Pi compatible camera
- PIR (motion) sensor
- Three female-female jumper wires
- Raspberry Pi power source
- Monitor, keyboard, and mouse to work with the Raspberry Pi
- Mounting putty or tape to hold up the camera, motion sensor, and Sense HAT
You’ll need to install the following through the Raspberry Pi terminal:
pip install imagemagick
pip install twython
-
Because we need GPIO pins for both the Sense HAT and for the PIR sensor, we’ll attach the mini black hat hack3r to the GPIO pins to extend their functionality. Make sure the ribbon wire connects to the GPIO pins such that it crosses over the body of the Raspberry Pi (RPi) and connects to the row of pins outside of the dotted lines

-
Connect the Sense HAT to the GPIO pins on the opposite side of the ribbon wire so that you still have access to the middle row of GPIO pins on the mini black hat hack3r

-
Connect one end of the three jumper wires to the PIR sensor, and connect the other end to the open GPIO pins according to the PIR pin labels that are underneath the removeable Fresnel lens (white cap) on the PIR:
- PIR Sensor VCC -> RPi 5V (green)
- PIR Sensor OUT -> RPi any GPIO numbered pin (yellow, on GPIO 4)
- PIR Sensor GND -> RPi any GPIO GND pin (orange)

-
Connect the Raspberry Pi camera to the camera port on the Raspberry Pi such that the blue strip points toward the RPi audio jack

-
Set up the RPi setup such that the camera, PIR sensor, and Sense HAT are at eye level—we used mounting putty to stick these on our monitor, but you can get creative and hold these up in any way that best fits your needs!

-
Plug in the mouse, keyboard, HDMI/monitor, and power supply to the RPi to power turn on the RPi
-
Install the packages listed in the Prerequisites section through the RPi terminal
-
Download the code file from the Github page, unzip the file, and save the DDR_CAMERA.py and auth.py files to the same file
-
Follow the instructions here to set up a Twitter account and get your access keys/tokens to make the Twitter bot portion of the RPi DDR game. Edit the auth.py file with your consumer key, consumer secret, access token, and access token secret information
-
Make sure that your camera is set up at a good angle by following the Getting Started with picamera instructions if you haven’t previously worked with the RPi camera
-
Run the DDR_Camera file, do the dance, see it post on your Twitter account, and enjoy!

