Construct a Carnival Buzzer Game with a Raspberry Pi

Create Announcement

This feature requires that you be logged in as a Google Classroom teacher and that you have an active class in Google Classroom.

If you are a Google Classroom teacher, please log in now.

For additional information about using Science Buddies with Google Classroom, see our FAQ.

Recommended Project Supplies
Get the right supplies — selected and tested to work with this project.
View Kit
Areas of Science Computer Science
Human Biology & Health
Difficulty
Time Required Very Short (≤ 1 day)
Prerequisites None
Material Availability This project requires a Complete Raspberry Pi Projects Kit, available from our partner Home Science Tools. The kit can be used to do seven other projects.
Cost Very High (over $150)
Safety No issues

Abstract

Have you ever played a game that tested the steadiness of your hands? Operation® is a popular board game that requires you to perform "surgery" without bumping a tool against the edges of the game. There are also popular amusement park or carnival games where you try to move a metal loop along a wavy metal wire without letting the two touch. You can build your own version of these games using the Raspberry Pi Projects Kit. Check out the video to see what this simple, but fun, project looks like:

Share your story with Science Buddies!

I did this project Yes, I Did This Project! Please log in (or create a free account) to let us know how things went.

Credits

Ben Finio, PhD, Science Buddies

Cite This Page

General citation information is provided here. Be sure to check the formatting, including capitalization, for the method you are using and update your citation, as needed.

MLA Style

Finio, Ben. "Construct a Carnival Buzzer Game with a Raspberry Pi." Science Buddies, 22 Nov. 2019, https://www.sciencebuddies.org/science-fair-projects/project-ideas/CompSci_p056/computer-science/carnival-buzzer-game-raspberry-pi?class=AQW04WKJlj_b0cisLMBfJL13vBP5-SB96ZBwH78ogL-sU4a6gChwcMQonnjw0_we4ZtF2l0qibtEySl9AFc9CuXOamWI1Y9kcd43wz0c4MUqTksI0KGSjzCKs5FBTSAOBqs. Accessed 15 Dec. 2019.

APA Style

Finio, B. (2019, November 22). Construct a Carnival Buzzer Game with a Raspberry Pi. Retrieved from https://www.sciencebuddies.org/science-fair-projects/project-ideas/CompSci_p056/computer-science/carnival-buzzer-game-raspberry-pi?class=AQW04WKJlj_b0cisLMBfJL13vBP5-SB96ZBwH78ogL-sU4a6gChwcMQonnjw0_we4ZtF2l0qibtEySl9AFc9CuXOamWI1Y9kcd43wz0c4MUqTksI0KGSjzCKs5FBTSAOBqs


Last edit date: 2019-11-22

Introduction

A Raspberry Pi (Figure 1) is a tiny computer that you can use to write programs and build and control your own electronic circuits, like the buzzer game in this project. The circuit uses sensors to gather information from the world around it. You can use information from those sensors to tell your computer program what to do. Many electronic devices we use every day, like phones and video game controllers, use sensors in the same way.

raspberry pi 3B+
Figure 1. A Raspberry Pi computer. (Image credit SparkFun Electronics, licensed under Creative Commons Attribution 2.0).

You can do this project just for fun, or turn it into an engineering or science project. To make it an engineering project, you will need to follow the engineering design process. Start by defining what you want your hand-steadiness game to be able to do, then work through the rest of the design process until you have a completed game to show off at your science fair.

If you want to use this for a science project, you will need to follow the scientific method. Start by coming up with a question for which you can use the game as a tool to help answer. For example, does age affect the steadiness of a person's hand? Have a large group of volunteers of different ages try the game. Do certain age groups score better than others?

Bibliography

News Feed on This Topic

 
, ,
Note: A computerized matching algorithm suggests the above articles. It's not as smart as you are, and it may occasionally give humorous, ridiculous, or even annoying results! Learn more about the News Feed

Materials and Equipment Product Kit Available

This project is written for the Science Buddies Raspberry Pi Projects Kit. There are two kit options available:

To set up your Raspberry Pi, you will also need the following parts (not included in either kit option):

  • TV or computer monitor with HDMI input*
  • USB keyboard and mouse

*If you have a TV or monitor with a DVI or VGA input, you will need an adapter. If your monitor does not have built-in speakers, you will need external speakers or headphones. See FAQ for more information.

To do this specific project, you will need the following circuit parts from your kit:

  • Male-male jumper wires (3)
  • Alligator clip leads (3)
  • Piano wire

You will also need the following materials, not included in your kit:

  • Metal paper clips (2), not plastic coated
  • Tape
  • Small piece of cardboard

Recommended Project Supplies

Get the right supplies — selected and tested to work with this project.
Project Kit: $199.95
View Kit

Experimental Procedure

Getting Started

In this project, you will make your own version of a classic carnival game, where you try to guide a metal loop along a bent metal wire without letting the two touch. If you have not already, you will need to set up your Raspberry Pi before you begin. Watch this video for an introduction to the project:

Writing Your Program

If you have never written a program in Scratch before, watch this video to learn how:

The objective of the game is to guide your paper clip "wand" down the bent wire, without letting the two touch, until you can tap the paper clip against the other paper clip at the bottom to win the game. If you touch the bent wire three times, you lose the game. So, you need a program that can do a few different things:

  • Play a sound when the paper clip wand touches the wire
  • Keep track of how many times the paper clip wand has touched the wire
  • Play different sounds for winning and losing the game
  • Automatically reset the game after you win or lose

The following program does just that. It consists of three if statements inside a forever loop. In addition to playing sounds, it also displays on-screen messages when you win or lose the game. This is a big program! Take your time and create a program based on the screenshot below, one block at a time. Remember to save your program frequently! You can also choose whatever sound effects you prefer from the Sounds tab.

raspberry pi 4.1 scratch program
Figure 2

If you get stuck, here are some helpful reminders for creating the program:

  • The set gpio __ to ____ and gpio __ is high? blocks are available under More blocks. If you do not see these blocks, click Add an extension, then click Pi GPIO and select OK.
  • To create a variable, click Data then Make a variable. Variables are convenient when you need to use a number multiple times in a program.
  • The __ = __ block can be found under Operators. You use this block to check if two numbers are equal to each other.
  • The Say ___ for __ secs block can be found under Looks. This will make the on-screen sprite show a word bubble with text.
  • The join __ __ block can be found under Operators. Use this to join together multiple strings of text, including variables.
  • The not __ block can be found under Operators. Along with an if block, you can use this block to check if a certain condition is not true.

icon learn

Learn More About:  How does the program work?

  [Show]

Building Your Game

To build the game, you will need some materials not included in your kit:

  • Two metal paper clips. Make sure they are not coated in plastic.
  • A small piece of cardboard
  • Tape (any type of tape will work)

You will also need one of the piano wires from your kit (you can also substitute a sheet of aluminum foil rolled into a very tight tube):

raspberry pi 4.1 piano wire
Figure 3

First, take two paper clips. Straighten them out, then bend one end of each paper clip into a loop.

raspberry pi paper clips
Figure 4

Next, bend one end of the piano wire into a "hook" shape, as shown below:

raspberry pi bent piano wire
Figure 5

Then, tape the bent end of the piano wire down flat to a piece of cardboard. Make sure the tip of the piano wire is poking up out of the tape (you will need to attach an alligator clip to it later). Wrap a second piece of tape around the straight part at the bottom of the piano wire.

raspberry pi taped piano wire
Figure 6

Loop one of the bent paper clips over the piano wire, and tape it down to the cardboard. Make sure there is tape in between the paper clip and the piano wire so they are not touching, or this will create a short circuit.

raspberry pi taped paper clips
Figure 7

Finally, bend your piano wire into whatever shape you want. The more "bendy" you make the wire, the harder the game will be. If you would rather start out by leaving the wire straight, and bend it later, you can do that instead.

raspberry pi bendy wire
Figure 8

Here is an example where the piano wire has been replaced with a tightly rolled tube of aluminum foil:

raspberry pi buzzer aluminum foil
Figure 9

Building Your Circuit

Next, you will need to build a circuit on a breadboard. If you have never used a breadboard before, watch this video to learn how:

To build the circuit, you will need three M-M jumper wires and three alligator clips:

M-M jumper wires
Figure 10
raspberry pi alligator clip red
Figure 11

Connect the jumper wires to the breadboard, as shown in Figure 12.

raspberry pi buzzer breadboard
Figure 12

raspberry pi buzzer breadboard photo
Figure 13

Then, connect alligator clips (with corresponding colors) to each of the jumper wires.

raspberry pi alligator clips closeup with foil
Figure 14

Finally, connect the other ends of the alligator clips to the parts of your game, as follows:

Alligator ClipGame Part
Green Piano wire or aluminum foil
Yellow Paper clip taped to cardboard  
Black Paper clip "wand"

raspberry pi buzzer alligator clips
Figure 15

Here is a picture of the complete setup:

raspberry pi buzzer game setup
Figure 16

Testing Your Game

Now you should be ready to test your game. Remember, the objective is to carefully guide the paper clip along the bendy wire without touching it, until you can reach the other paper clip at the bottom.

raspberry pi buzzer game test
Figure 17

Click the green flag to start your program. After the "gong" sound plays, try the game! Challenge your friends and family to play as well. If you find the game to be too easy or too hard, there are a few different things you can adjust:

  • To make the game easier:
    • Straighten out the piano wire.
    • Make the paper clip loop bigger.
    • Increase the delay1 variable.
    • Increase the number of times you can touch the wire before losing (change the number in the count = 3 block in your program).
  • To make the game harder:
    • Put more bends in the piano wire.
    • Make the paper clip loop smaller.
    • Decrease the delay1 variable.
    • Decrease the number of times you can touch the wire before losing (change the number in the count = 3 block in your program).

icon trouble

Troubleshooting:  My game does not work!

  [Show]

Going Further

There are a lot of fun things you can do to expand your game. Here are just a few suggestions:

  • Add a single LED to your circuit that lights up briefly when you touch the piano wire.
  • Add three LEDs to your circuit, like at the end of the demo video. Make one more LED light up and stay lit each time you touch the piano wire. Turn all the LEDs off again when the game resets. See the diagram below if you need help hooking up the LEDs, and refer to the Light-Up Piano project if you need help with the Scratch code.
  • Add a counter to the game by creating a variable that increases by 1 for every completion of the forever loop. Use this timer as a "score" for the player; the faster you complete the game, the better your score.
  • Create a countdown timer that starts at a certain value and decreases by 1 for every completion of the forever loop. Make the player lose if time runs out. This will add some pressure to the game!
  • For a big programming challenge, try to make a multi-player game. Let multiple players take turns trying the game, and keep score for each one (using one of the timer methods above, or based on who hits the wire the fewest times). Announce which player is the winner, based on who has the best score.
  • For another challenge, make your program keep track of the "high score" (using one of the methods above). Display the current high score on screen, and update it if a player manages to beat the high score.

Here's a breadboard diagram of the circuit with three LEDs added (remember that the green, yellow, and black jumper wires on the left connect to the alligator clips):

raspberry pi buzzer 3 LEDs
Figure 18
.

Troubleshooting

For troubleshooting tips, please read our FAQ: Construct a Carnival Buzzer Game with a Raspberry Pi.

If you like this project, you might enjoy exploring these related careers:

physical therapist helping girl walk

Physical Therapist

If you are injured in an accident, suffer a stroke, heart attack, or loss of a limb, or are born with conditions that make it difficult to move your body, then you will often be cared for by a physical therapist. Physical therapists review a patient's medical history, test and measure his or her physical condition (things like range of motion, strength, flexibility, balance, coordination, muscle function), and then develop a treatment plan to meet some physical goals. They coach, motivate, and educate the patient to follow the plan and work on therapies that will restore, maintain, or promote physical fitness and health. Physical therapists also act as advocates, bringing a patient's health needs to the attention of other workers on a patient's healthcare team, such as physicians, speech therapists, or respiratory therapists. Read more
electrical engineer aligning laser

Electrical & Electronics Engineer

Just as a potter forms clay, or a steel worker molds molten steel, electrical and electronics engineers gather and shape electricity and use it to make products that transmit power or transmit information. Electrical and electronics engineers may specialize in one of the millions of products that make or use electricity, like cell phones, electric motors, microwaves, medical instruments, airline navigation system, or handheld games. Read more
Computer programmer typing on a keyboard

Computer Programmer

Computers are essential tools in the modern world, handling everything from traffic control, car welding, movie animation, shipping, aircraft design, and social networking to book publishing, business management, music mixing, health care, agriculture, and online shopping. Computer programmers are the people who write the instructions that tell computers what to do. Read more
NASA flight software engineer

Computer Software Engineer

Are you interested in developing cool video game software for computers? Would you like to learn how to make software run faster and more reliably on different kinds of computers and operating systems? Do you like to apply your computer science skills to solve problems? If so, then you might be interested in the career of a computer software engineer. Read more


Share your story with Science Buddies!

I did this project Yes, I Did This Project! Please log in (or create a free account) to let us know how things went.

Frequently Asked Questions (FAQ)

If you are having trouble with this project, please read the FAQ below. You may find the answer to your question.

Kit General Questions

Setting Up and Using Your Raspberry Pi FAQ

These answers apply to the Raspberry Pi Model 3B+ which comes with the Raspberry Pi Projects Kit. If you are using a different Raspberry Pi model you will need to do some research on your own—we suggest starting with the Raspberry Pi Foundation's Setting up your Raspberry Pi page.

Kit General Answers

Q: Who is the kit appropriate for?
A: The kit is meant for anyone (ages 8 and up) who wants to learn some basic programming and electronics skills while having fun. Students up to age 10, or older if their reading skills are behind grade level, may need adult assistance in reading and following the on-screen instructions. The projects included in the kit were beta tested and approved by students ages 8 to 16.

Q: Are the kit parts reusable?
A: Yes, all the electronics components in the kit can be re-used to do new projects or to repeat the projects.

Q: Aren't there other Raspberry Pi kits on the market? How is yours different?
A: Yes, there are other Raspberry Pi kits, and some of them are quite good! The Raspberry Pi Projects Kit and Raspberry Pi Circuit Parts Only Kit have been designed to contain the specific materials needed to do the accompanying Science Buddies Raspberry Pi projects. Our kit and associated projects are specifically meant for people who have no prior experience programming or connecting circuits. The projects are 100% beginner friendly with clear on-screen instructions, pictures, and videos. We think the kit, with its associated projects, is one of the most fun kits out there! But, if you are already an ace programmer or electronics guru, you may not find this the best fit for your own personal use. Even so, it may be a fun way for you to introduce others to programming and electronics.

Q: I already have a Raspberry Pi. Can I just buy the circuit parts separately?
A: Yes! We sell two different kits: the Raspberry Pi Projects Kit which includes a Raspberry Pi and the required accessories, and the Raspberry Pi Circuit Parts Only Kit, which only contains the additional circuit parts you need to do the Science Buddies projects. Both kits contain an SD card with the Raspbian operating system and a desktop shortcut to the Science Buddies project instructions.

Q: What programming language do the projects use?
A: The projects use Scratch 2. Scratch is a "graphical" programming language developed by the MIT Media Lab. It allows you to write code by clicking, dragging, and snapping together color-coded blocks. This allows beginners to write working code without worrying about formatting or typos. On the Raspberry Pi, Scratch allows you to control the general purpose input and output (GPIO) pins so your program can interact with a circuit in the physical world.

Note: three different versions of Scratch (1, 2, and 3) are available for the Raspberry Pi. The instructions for the Science Buddies projects (including example code) are specifically written for Scratch 2, which runs well on the Raspberry Pi model 3B+. If you have an older model Raspberry Pi, Scratch 2 may run more slowly, or may not run at all. If you want to use a different version of Scratch, you will need to consult the official documentation for Scratch 1.4 or Scratch 3 and modify the programming steps accordingly.

Setting Up and Using Your Raspberry Pi FAQ Answers

Q: How do I connect my Raspberry Pi to my TV or computer monitor?
A: The easiest way to set up your Raspberry Pi is to use an HDMI cable (included in the Science Buddies Raspberry Pi Projects Kit) to connect to a TV or computer monitor that has built-in speakers. If you are using a computer monitor with an HDMI port but no built-in speakers, you will also need separate speakers or headphones with a 3.5 mm audio plug (a regular "headphone jack").

If your TV or monitor does not have an HDMI port, you will need an HDMI to DVI or HDMI to VGA adapter (see pictures in table below). DVI and VGA do not transmit sound, so you will need separate headphones or speakers if you are using one of those options.

HDMI DVI VGA
HDMI port
DVI port
VGA port

Q: Can I use a laptop as a display and/or keyboard?
A: The short answer is "not easily." Many newer laptops have HDMI ports, but they only function as HDMI out, to send a video signal from the laptop to a television or projector. They do not work as HDMI in to display an external signal on the laptop's screen. The laptop's keyboard is only designed to work with the laptop itself, not as a standalone keyboard for an external device like the Raspberry Pi.

The longer answer is that, similar to the Remote Desktop feature on Windows and Mac computers, you can use special software to remotely operate a Raspberry Pi that is connected to the internet. This would allow you to control a Raspberry Pi using your laptop's screen and keyboard. This option is only recommended for advanced users, and you can find instructions here.

Q: How do I connect my Raspberry Pi to the internet?
A: Unlike earlier models, the Raspberry Pi 3B+ contains built-in Wi-Fi functionality. It does not require an external USB Wi-Fi adapter. You can connect your Raspberry Pi to the internet by clicking the internet icon in the taskbar and searching for available Wi-Fi networks, just like you would on a Windows or Mac computer. Your Raspberry Pi also has an ethernet port, which you can use to plug directly into a router for a hardwired connection.

Q: How do I shut down or reboot my Raspberry Pi? There's no power button!
A: Unlike most computers, the Raspberry Pi does not have a power button. You can shut down or reboot by clicking the raspberry icon in the upper left corner of your desktop, then select Shutdown. After the Raspberry Pi has shut down, it is safe to unplug the micro-USB power cable. Plug the cable back in to reboot. Important: never unplug the power cable while the Raspberry Pi is still running. This can corrupt the SD card.

Q: How can I adjust the Raspberry Pi's display resolution?
A: Click the Raspberry Pi logo in the top-left corner of your desktop. Select Preferences, then Raspberry Pi Configuration, then click the Set Resolution... button on the System tab.

Q: I have everything connected properly. Why can't I hear any sound?
A: Right-click the speaker icon on the desktop taskbar. This allows you to manually select HDMI or analog (the headphone jack) for sound output. Make sure you have the proper output selected. Also, make sure your Scratch program is set to play a sound. You can write a simple program to test if your sound is working using the "when space key pressed" and "play sound meow" blocks.

Q: Why won't my Raspberry Pi turn on?
A: If your Raspberry Pi will not turn on (the screen remains blank after everything is plugged in), go through this checklist to make sure everything is set up properly.
  1. Make sure your SD card is pushed in all the way (see Figure 1).
  2. Make sure the red power LED on your Raspberry Pi (labeled "PWR," near the micro-USB port, see Figure 2) is on. This means the Raspberry Pi is receiving power from the micro-USB port. If the LED is not on, make sure you pushed the micro-USB connector into the micro-USB port all the way.
  3. When you first plug the micro-USB cable in, the green LED (labeled "ACT," next to the PWR LED, see Figure 2) should flash several times. This LED flashes when the Raspberry Pi reads data from the SD card. After the Raspberry Pi is done booting up, it should turn off. If it does not flash at all, your SD card might not be inserted properly. Go back to step 1.
  4. Make sure your display (television or monitor) is turned on. If your display is turned off, you will not see anything on the screen, even if the Raspberry Pi is on.
  5. Make sure your display is set to the correct input. Many modern TVs have more than one HDMI input, and some computer monitors have DVI or VGA inputs in addition to HDMI.

Raspberry Pi SD card inserted properly and not all the way in
Figure 1. A micro-SD card that is inserted properly (left) and one that is not pushed in all the way (right).

Raspberry Pi status LEDs
Figure 2. The PWR (red) and ACT (green) LEDs near the micro-USB port.


Q: My Raspberry Pi starts to boot up, but then it freezes or the screen goes blank. What is wrong?
A There may be a problem with your Raspberry Pi or SD card. If you are using the Raspberry Pi or SD card that came with the Raspberry Pi Projects Kit or Raspberry Pi Circuit Parts Only Kit purchased from our partner Home Science Tools, please contact them directly at service@homesciencetools.com for assistance.

Q: My Raspberry Pi froze and is not responding to mouse or keyboard input. What should I do?
A: First, be patient and give the Raspberry Pi a few minutes to try and process whatever it was doing. If you click on a whole bunch of things in rapid succession, or run a really complicated Scratch program, the Raspberry Pi might slow down or freeze temporarily.

Next, if you are using a wireless keyboard and mouse, make sure they have fresh batteries.

Finally, as a last resort, if your Raspberry Pi is not responding, unplug the micro-USB cable and plug it back in. In general, you want to avoid doing this, because suddenly cutting power to the Raspberry Pi without properly shutting it down first can corrupt the SD card, and prevent the Raspberry Pi from working properly.

Q: My Raspberry Pi is acting strangely (e.g. it suddenly will not boot up properly, certain programs do not work, etc.). What is wrong?
A: If your Raspberry Pi is not "dead," but seems to be behaving strangely, there is a chance that your SD card has become corrupted. This can happen if you unplug the Raspberry Pi's power cord without properly shutting it down first. See the next question.

Q: I think I corrupted my Raspberry Pi's SD card. What should I do?
A: If the SD card came with the Raspberry Pi Projects Kit or Raspberry Pi Circuit Parts Only Kit you purchased from our partner Home Science Tools, please contact them directly at service@homesciencetools.com for assistance. Make sure to include a detailed description of the problem you are having. They will work with you to resolve the issue.
Q: I need help with a question, related to my Science Buddies Raspberry Pi Projects Kit or Raspberry Pi Circuits Parts Only Kit, not listed here. Who can I ask?
A: Science Buddies has a special area of our Ask an Expert forums dedicated to the Raspberry Pi Projects Kit. Please note that the forums are staffed by volunteers, and it may take a few days to get a response. If you are doing a science project, please do not wait until the day before the project is due to ask an urgent question.

Ask an Expert

The Ask an Expert Forum is intended to be a place where students can go to find answers to science questions that they have been unable to find using other resources. If you have specific questions about your science fair project or science fair, our team of volunteer scientists can help. Our Experts won't do the work for you, but they will make suggestions, offer guidance, and help you troubleshoot.

Ask an Expert

Contact Us

If you have purchased a kit for this project from Science Buddies, we are pleased to answer any question not addressed by the FAQ above.

In your email, please follow these instructions:
  1. What is your Science Buddies kit order number?
  2. Please describe how you need help as thoroughly as possible:

    Examples

    Good Question I'm trying to do Experimental Procedure step #5, "Scrape the insulation from the wire. . ." How do I know when I've scraped enough?
    Good Question I'm at Experimental Procedure step #7, "Move the magnet back and forth . . ." and the LED is not lighting up.
    Bad Question I don't understand the instructions. Help!
    Good Question I am purchasing my materials. Can I substitute a 1N34 diode for the 1N25 diode called for in the material list?
    Bad Question Can I use a different part?

Contact Us

Related Links

News Feed on This Topic

 
, ,
Note: A computerized matching algorithm suggests the above articles. It's not as smart as you are, and it may occasionally give humorous, ridiculous, or even annoying results! Learn more about the News Feed

Looking for more science fun?

Try one of our science activities for quick, anytime science explorations. The perfect thing to liven up a rainy day, school vacation, or moment of boredom.

Find an Activity