Pong is one of the earliest arcade video games, originally released in 1972 by Atari. It is a table tennis game featuring simple two-dimensional graphics. Players control paddles on each side of the screen, which they use to hit a ball back and forth.
For inspiration, play this game online with friends and make a competition out of it.
Create a Pong game using Python and Raspberry Pi but at first read the articles and look at the videos given in this lesson to get an idea behind Raspberry Pi and Pong game itself.
You will need:
- A Raspberry Pi
- A Raspberry Pi Build HAT
- At least 1 Lego Technic motor
- Assortment of LEGO®, including wheels (we used a selection from the LEGO® Education SPIKE™ Prime kit)
- A small breadboard (optional)
- A buzzer (optional)
- Some breadboard jumper leads (optional)
- A 7.5V power supply with a barrel jack (optional). You can use an official Raspberry Pi power supply for this project, as the motor encoders will not be using any power
Get an idea behind all of the things listed above before you go ahead with this lesson.
In this project, you will use the Raspberry Pi BUILD HAT, a LEGO Technic motor encoder and wheel, and the python turtle library, to make a simple game controller that you can use to play Pong.
1. Group discussion.
Discuss the questions below with your friends:
- Have you ever heard about this? Have you seen it?
- Would you know how and where it is used?
- Do you know what a Pong game is? Have you ever played it?
- Have you thought about, what makes it work and how?
- Can playing a game like this, can ease the stress or make one more competitive?
2. Look at the links given in Resources and start thinking about how you could program and how.
3. Before you start, you’ll need to have set up your Raspberry Pi Computer and attached the Build HAT (page 7 in "LEGO pong pdf.")
4. Power up your Raspberry Pi using the 7.5V barrel jack on the Build HAT, which will allow you to use the motors (page 8 in "LEGO pong pdf.")
5. You will need to install the BuildHat Python library by following the instructions give on page 9 in "LEGO pong pdf."
6. Next follow the steps given in "LEGO pong pdf." starting from the page 10.
- Using the LEGO Spike motor encoders - look at the motors and try to find out what are encoders and how they work; move it
- Connect a monitor, keyboard, and mouse to your Raspberry Pi device.
- Connect your Build HAT to your Raspberry Pi with the printed logo facing up, making sure that you have properly covered all the pins.
- Lastly, connect the power; either through the Build HAT barrel jack or the USB-C port on the Raspberry Pi.
For the next steps, ask from the teacher and make a Pong Game together.
If you are master in programming, make an awesome game for your teacher to play for exmple.
- Now you should be able to make something run on Raspberry Pi by using Python.
- You should be able to find material on your topic or anything you want to program.
- You should know the basic steps to take to code with Python on Raspberry Pi.
- Create your own game and share it.
- Make a competition challange with Pong Game or create something unique.
You have completed the project
If you are interested in ways you might improve your project, find more about how you can do that here.
- Learn how to read the degrees of rotation from LEGO Technic motors.
- Learn to draw and move Turtle graphics using LEGO Technic motors.
- Learn to detect collisions between graphics using x and y coordinates.
- Leran thinking, logic and mathematical skills