diff options
author | Cristian Maglie <c.maglie@bug.st> | 2013-01-27 12:52:06 +0100 |
---|---|---|
committer | Cristian Maglie <c.maglie@bug.st> | 2013-01-27 12:52:06 +0100 |
commit | 76d436f51501bd47ff463b88a196f517191f58ad (patch) | |
tree | 1f22ba2385ad22eca306d67793c0827451f2b50a /libraries/Esplora/Experts/EsploraPong | |
parent | bb9cc4f70c17eed497ab30d7bfe6eebb35055205 (diff) | |
parent | c6287dd6ac33544179a6544b8f3f55a396ec6608 (diff) |
Merge branch 'ide-1.5.x' into can
Diffstat (limited to 'libraries/Esplora/Experts/EsploraPong')
-rw-r--r-- | libraries/Esplora/Experts/EsploraPong/EsploraPong.ino | 44 |
1 files changed, 44 insertions, 0 deletions
diff --git a/libraries/Esplora/Experts/EsploraPong/EsploraPong.ino b/libraries/Esplora/Experts/EsploraPong/EsploraPong.ino new file mode 100644 index 0000000..725a109 --- /dev/null +++ b/libraries/Esplora/Experts/EsploraPong/EsploraPong.ino @@ -0,0 +1,44 @@ +/* + Esplora Pong + + This sketch connects serially to a Processing sketch to control a Pong game. + It sends the position of the slider and the states of three pushbuttons to the + Processing sketch serially, separated by commas. The Processing sketch uses that + data to control the graphics in the sketch. + + The slider sets a paddle's height + Switch 1 is resets the game + Switch 2 resets the ball to the center + Switch 3 reverses the players + + You can play this game with one or two Esploras. + + Created on 22 Dec 2012 + by Tom Igoe + + This example is in the public domain. + */ + +#include <Esplora.h> + +void setup() { + Serial.begin(9600); // initialize serial communication +} + +void loop() { + // read the slider and three of the buttons + int slider = Esplora.readSlider(); + int resetButton = Esplora.readButton(SWITCH_1); + int serveButton = Esplora.readButton(SWITCH_3); + int switchPlayerButton = Esplora.readButton(SWITCH_4); + + Serial.print(slider); // print the slider value + Serial.print(","); // add a comma + Serial.print(resetButton); // print the reset button value + Serial.print(","); // add another comma + Serial.print(serveButton); // print the serve button value + Serial.print(","); // add another comma + Serial.println(switchPlayerButton); // print the last button with a newline + delay(10); // delay before sending the next set +} + |