two potentiometers as pong controllers

Hi everybody!!! i would like to know if it is possible to use two potentiometers ,connected to A0 and A1 analog pin of arduino uno, as controllers for a multiplayer pong that I wrote with processing. Can I send two different values through serial port and read them with processing??

thank you!

Totally possible

On the arduino side, you just need to get the analog value (the 0-1023)for each of the pots. (you might needs some extra circuitry to trim the pots as needed) take those 2 values, and send them into the com port with some naming convention. Somethign like (A denotes player 1, B is player 2, though you can use whatever)

serial.print ('A'); serial.print (player A's position); serial.print ('B'); serial.println (player B's position);

Then something in the processing code should pick that up, split it into variables for A's position and B's position. And then put those into the game

Someone can probably give a much better example of the coding needed though, sorry I can't be more helpful

Make sure that the frequency of sending position updates from the Arduino is less than the maximum capacity of the serial link. If you saturate the link your updates will be buffered on the sending side, resulting in extra latency.

ok, but once i send the data how can I read and split it into the two values i need with processing?

Processing has a split function. Do a search in the Processing forum on how to use it.

is there anybody who can tell me something more precise??
what should i do on Arduino and what on processing?

For the Arduino side, write a sketch which reads your potentiometer positions at regular intervals and prints the two values to the serial port in a format which you will define. The 'blink without delay' example sketch shows you how to do things at regular intervals. Choose the interval so that the total amount of serial output is comfortably less than the amount the serial link can carry at the speed you are running it at.

On the Processing side, modify your game to read input from the serial port, parse it according to the message format you have chosen, and pass the two potentiometer values to your game as player inputs.

Thank you!!!!!!!! :)

PeterH: For the Arduino side, write a sketch which reads your potentiometer positions at regular intervals and prints the two values to the serial port in a format which you will define. The 'blink without delay' example sketch shows you how to do things at regular intervals. Choose the interval so that the total amount of serial output is comfortably less than the amount the serial link can carry at the speed you are running it at.

On the Processing side, modify your game to read input from the serial port, parse it according to the message format you have chosen, and pass the two potentiometer values to your game as player inputs.

Please, can u give me an example of a format i could define to send the message?

NugsCut: Please, can u give me an example of a format i could define to send the message?

The simplest format would be an ascii text message containing the two decimal numbers. You could just print out the two numbers separated by a comma:

25,52

This is easy to parse on the receiving side by splitting the string at the comma and then converting the two sub-strings to integers.

I did it!!!!! :)

https://www.facebook.com/photo.php?v=10200930073755288&l=4341658863431678801

ps. thank you a lot PeterH for the Help! finally i used firmata!