Whoo-Pi Cushion with Raspberry Pi
Build a high-tech whoopee cushion prank using Raspberry Pi, GPIO, and custom sound effects.
- Raspberry Pi
- Beginner
- 60 minutes
- 5 steps
Shop this project
CartYou'll need
Prices from vilros.com. Tax and shipping at checkout.
Before you start, you'll need
- Raspberry Pi (any model with GPIO)
- 2 paper plates
- Paper clips
- Scissors
- Cardboard
- Copper tape
- Sticky tape
- Sponges
- Glue
- Aluminum foil
- 2 crocodile clip cables
- 2 male-to-female jumper leads
- Speaker or headphones
Build the pressure cushion
About 20 minutes
Create a pressure-sensitive switch using plates and foil.
- Cut two cardboard circles to fit inside the deep part of the paper plates.
- Attach aluminum foil strips to each cardboard circle using sticky tape. Make the strips long enough to reach the plate's lip.
- Use copper tape to fasten the foil strips to the edge of each plate to maintain conductivity.
- Cut sponge into cubes and glue them around the foil on one plate to keep the foil strips separated.
- Position the two plates so the foil strips face each other but don't touch.
- Tape the plates together or use paper clips to hold them.
You should see
The cushion is assembled. The foil strips don't touch until pressure is applied.
Connect the cushion to Raspberry Pi
About 10 minutes
Wire the cushion as a button input.
- Plug one jumper cable into a GND pin on your Raspberry Pi.
- Plug the other jumper cable into GPIO pin 2.
- Use crocodile clip cables to connect the copper tape strips to the male pins of the jumpers.
- Connect one copper strip to GND and the other to GPIO 2.
You should see
The cushion is wired to your Raspberry Pi's GPIO pins.
Download sound effects
About 10 minutes
Find and prepare sound files for playback.
- Create a folder called 'whoopi' in your home directory.
- Download funny sound effects in .wav format (search online or record your own).
- Save at least 3 sound files in the 'whoopi' folder.
- Test playback using the aplay command in Terminal.
- Configure audio output to the headphone jack.
amixer cset numid=3 1This switches audio output to the 3.5mm headphone jack. Use 2 for HDMI audio.
You should see
Sound files play successfully through your speakers or headphones.
Write the Python program
About 15 minutes
Create a script that plays a random sound when the cushion is pressed.
- Open Python 3 (IDLE) and create a new file.
- Save it as 'whoopi.py' in the whoopi folder.
- Import the necessary libraries (os, random, time, gpiozero).
- Create a list of your sound file names.
- Write a loop that waits for button presses and plays a random sound.
import os
import random
from time import sleep
from gpiozero import Button
button = Button(2)
sounds = ['fart1.wav', 'fart2.wav', 'fart3.wav']
while True:
button.wait_for_press()
sound = random.choice(sounds)
os.system("aplay {0}".format(sound))
sleep(2)Replace the sound file names with your actual .wav files. The sleep(2) prevents rapid re-triggering.
You should see
The script runs without errors.
Test your Whoo-Pi Cushion
About 5 minutes
Verify the cushion triggers sounds when pressed.
- Run your Python script.
- Place the cushion on a chair (hide the wires if possible).
- Sit on the cushion and listen for a random sound to play.
- If nothing happens, check the wiring and ensure the foil strips make contact when pressed.
You should see
Sitting on the cushion triggers a random sound from your list.
It didn't work
No sound plays when the cushion is pressed.
Check that the foil strips make good contact when pressed. Verify the GPIO wiring (GPIO 2 and GND). Test the button connection with a simple gpiozero script first.
Sound plays constantly or triggers multiple times.
The sponges may be too compressed, causing the foil to touch constantly. Add more sponge cubes to increase separation. Increase the sleep() delay in the code.
What to do next
- Electronic GardenBuild another fun Raspberry Pi project with motors.
- More Raspberry Pi projectsExplore beginner Raspberry Pi builds.
Stuck? Contact Vilros Support with your board model and what you see on screen.