Introduction: 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
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