loading

In this tutorial we are going to build an arduino-based controller that we can use to play pong.

We are going to use a dial potentiometer (a turning knob) to control the pong bat/paddle.

Step 1: Wire Up Your Arduino

The first job is to connect three wires to your arduino:

  • A blue wire into analog pin A0
  • A black wire into one of the GND (ground) pins
  • A red wire into the 5v pin

Step 2: Connect Your Potentiometer

Next we connect the wires to a dial potentiometer (here we use a 10k potentiometer, but most other types will also work). Connect the black wire to the first pin, the blue to the second and the red to the third (as show in the photo).

Step 3: Write Your Code

The next step is to write some code to read the current value of the potentiometer and pass it on via the USB cable to your computer.

Download the PotPong.ino file, open it up in the Arduino application and upload it onto your Arduino.

Note: In order to connect to the pong game in the next step of this tutorial, you are going to need to know which serial port your Arduino is attached to. Make a note of the port name at the bottom right of the Arduino window (see the red box in the above screenshot). If you have a Mac, the name will start with "/dev" if you have a Windows computer the name will start with "COM".

Step 4: Run the Pong Game

We have written a pong game for you to use - download the Pong.zip file and unzip it.

To run the pong game, you are going to need to install the Processing programming tool

Once you have installed Processing, simply open up the Pong project file.

Before you can run the game, you need to tell the programme which serial port your Arduino is attached to.

Find the line that starts with String serialPortName and enter in the serial port name you found earlier.

For example, on a Mac it would be something like:

String serialPortName = "/dev/cu.usbmodem1421";

or on Windows, something like:

String serialPortName = "COM1";

Step 5: Enjoy

If everything worked, when you press the run/play button in Processing (found at the top left of the window) you should be able to control the Pong bat/paddle using the potentiometer.

If you enjoyed this instructable, check out our other tutorials

If you love this kind of stuff, check out our degree

Tjere is a problem how to solve it?
<p>Hey there! I've just solved this problem... In proccesing, you have to go<br><br>Sketch&gt; Import Library&gt; Add library... and search and install these:<br><br>processing.serial</p><p>Minim<br><br>And them enjoy :)</p>
Ok thanks for replying!
Does arduino uno works (here you use the Leonardo)
<p>yes - should work just fine with an UNO</p>
<p>its really good thanks</p>
<p>its really good thanks</p>
<p>is it matlab based or what program?</p>
the pong game is written in Processing
<p>Some improvements based on this great instructables post:</p><p>http://projectlog.ferranfabregas.info/creating-a-pc-2-players-pong-game-controller-with-arduino-and-processing/</p><p>I hope you like it!</p>
<p>Sweet !</p>
<p>Such a cool idea! I'd love the see a video of it in action! </p>

About This Instructable

13,530views

164favorites

License:

Bio: Tutorials provided by BA/BSc (Hons) Digital Art and Technology at Plymouth University
More by Digital Art and Technology:Green space activity monitor Python Micro:bit Light Show Jumpstarting a Hot-glued Arduino 
Add instructable to: