Introduction: Photo Resistor Controlled Arduino Pong With Processing

Picture of Photo Resistor Controlled Arduino Pong With Processing

In the electrical engineering strand at the Governors Institute of Vermont 2014 our challenge was to create a project using an arduino that had an interactive mode and an autonomous mode. Our group decided to remake the classic pong game using the arduino as a controller and the processing 2.2.1 engine as the display on our laptop monitor. The electronics and wiring for the arduino are relatively simple, but the code and process of having arduino communicate with processing was difficult. Our main struggle was figuring out how to set which com port processing should listen to, but after processing began listening to the correct com port the process was much easier.

Step 1: Creating the Controller

Picture of Creating the Controller

For the Controller our group used an arduino uno, four photocells, 4 10k ohm resistors, various lengths of wire, and 2 breadboards which could be assembled onto a single larger breadboard, but we didn't have any large breadboards available. The four photocells are powered by the 5 volt pin on the arduino and are placed as far apart as possible to avoid interference between signals.

Step 2: Arduino Code

The source code for the controller and pong code originates from:

http://teachmetomake.com/wordpress/arduino-and-pro...

for our project we modified this code to have four inputs instead of two because our setup utilizes two photocells per player, instead of a single potentiometer per player such as in the original project. The Controller code works both with the one player mode and two player mode of the pong game, and it is fairly straightforward. The code reads the values which are output by the photocells and sends each value by serial communication to the processing engine.

Step 3: Processing and Pong

Again the Source code for the processing side of the pong game can be found at the following URL:

http://teachmetomake.com/wordpress/arduino-and-pro...

A download for the Processing 2.2.1 can also be found at the following URL:

https://www.processing.org/download/?processing

An explanation of what processing exactly is can also be found at the homepage of the above URL.

Our modifications to the two player processing code were minimal and mostly served to have the pong game listen for four input values instead of the normal two values, otherwise the two player version is a standard pong game. Our single player variation of pong is the two player mode, but with a wall on one side, a single controllable paddle, and a timer at the top to test your ability to survive. The value in the upper left corner of the single player variation is your longest time trial of your current session, and the value in the upper right corner is the length of your current trial. We have experienced issues of the ball getting caught in the wall which have yet to be completely fixed; we would appreciate feedback on possible remedies to this problem.

Step 4: Sources

"Arduino Optical Theremin." Instructables.com. N.p., n.d. Web. 11 July 2014

"Teach Me To Make." Teach Me To Make. N.p., n.d. Web. 11 July 2014.

Comments

Aleator777 (author)2014-07-11

Also, you provided links in your Instructable, so there's no need for the fourth "Source" step :)

Aleator777 (author)2014-07-11

Seems like a fun way to interface with the game. Quiet too!