Tutorial.EsploraPong History

Hide minor edits - Show changes to output

December 24, 2012, at 04:00 PM by Scott Fitzgerald -
Changed lines 35-36 from:
The data is always sent in the same order: slider, button 1, button 3, button 4. The data are separated by commas. The Serial.println() command that sends the final button also sends a newline character. The Processing sketch looks for the newline to know when it's got all the sensor data.
to:
The data is always sent in the same order: slider, button 1, button 3, button 4. The data are separated by commas. The [[Serial/Println | Serial.println]]() command that sends the final button also sends a newline character. The Processing sketch looks for the newline to know when it's got all the sensor data.
December 24, 2012, at 03:57 AM by Tom Igoe -
Changed lines 37-38 from:
to:
'''NOTE: Serial ports on a computer can only be accessed by one program at a time.''' If you have the Arduino IDE's Serial Monitor open, then the Processing Sketch will not be able to access the Esplora's serial port. Likewise, if the Processing sketch is still running, you won't be able to open the Serial Monitor or reprogram your Esplora.
December 24, 2012, at 03:55 AM by Tom Igoe -
Changed line 24 from:
Only your Arduino Espora is needed for this example.
to:
Only your Arduino Esplora is needed for this example.
December 24, 2012, at 03:46 AM by Tom Igoe -
Added lines 1-46:
''Examples > Esplora''

!!!Esplora Pong

Want to play Pong on your computer with your Esplora? This example shows you how.

This example is designed to be used with a Processing sketch. Processing is an open source programming environment. The Esplora reads the slider and buttons and sends data to the Processing sketch serially over USB, and Processing uses the incoming data to move paddles in a game of Pong.

If you don't have [[http://www.processing.org | Processing]] installed on your computer, [[http://www.processing.org/download/ | download it]] from the Processing site and follow the installation instructions.

[[Attach:ProcessingPong.zip | Download the zip file]] containing the Processing sketch for this example.

You only need to unzip this folder inside your Processing sketches folder, and open the .pde file in Processing.

(:div class=BOM :)
!!!Hardware Required
* Arduino Esplora

!!!Software Required
* [[http://processing.org | Processing]]
(:divend:)

!!!Circuit
Only your Arduino Espora is needed for this example.
%height=350px%[[Attach:Esplora_Pong.png | Attach:Esplora_Pong.png]]
[- Esplora board using slider and pushbuttons -]

(:divend:)


!!!Code

This example sends the states of the slider and three pushbuttons serially to the computer. The associated Processing sketch reads the serial data to control the paddles and the state of the game.

The data is always sent in the same order: slider, button 1, button 3, button 4. The data are separated by commas. The Serial.println() command that sends the final button also sends a newline character. The Processing sketch looks for the newline to know when it's got all the sensor data.


(:div class=code :)
(:source
https://raw.github.com/arduino/Arduino/master/libraries/Esplora/examples/Experts/EsploraPong/EsploraPong.ino lang=arduino tabwidth=4:)
(:divend:)


!!!See Also:

* [[Reference/EsploraLibrary | Esplora Library]]

Share