Introduction: Getting Started With Arduino - Potentiometer Pong

Picture of Getting Started With Arduino - Potentiometer Pong

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

Picture of 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

Picture of 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

Picture of 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

Picture of 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

Picture of 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

Comments

Loufourmountains (author)2016-06-30

Tjere is a problem how to solve it?

Hey there! I've just solved this problem... In proccesing, you have to go

Sketch> Import Library> Add library... and search and install these:

processing.serial

Minim

And them enjoy :)

Loufourmountains (author)2016-06-30

Ok thanks for replying!

Loufourmountains (author)2016-06-29

Does arduino uno works (here you use the Leonardo)

yes - should work just fine with an UNO

Jeremy the robot made it! (author)2016-05-21

its really good thanks

Jeremy the robot made it! (author)2016-05-21

its really good thanks

JairoF2 (author)2015-11-09

is it matlab based or what program?

the pong game is written in Processing

DIYProjectLog (author)2015-07-18

Some improvements based on this great instructables post:

http://projectlog.ferranfabregas.info/creating-a-pc-2-players-pong-game-controller-with-arduino-and-processing/

I hope you like it!

DIYProjectLog (author)2015-07-18

tomatoskins (author)2015-07-16

Such a cool idea! I'd love the see a video of it in action!

About This Instructable

14,333views

165favorites

License:

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