Java Solaris Communities Partners My Sun Sun Store United States Worldwide
»   Introduction
» A Short Tour of a Sun SPOT
    The Ectoplasmic Bouncing Ball Demo (current page)
»   Loading and Running the Air Text Demo
»   Changing the Air Text Demo
» Basestation in Action
 
Sun SPOT Quick Start Tutorial

The Ectoplasmic Bouncing Ball Demo

 
 
Set-up

You need two free-range Sun SPOTs. The Sun SPOTs come with the Ectoplasmic Bouncing Ball demo already loaded, so just turn the free-range Sun SPOTs on.

The Effect

In this demo, the row of LEDs on the top board of each Sun SPOT represents a tube. Note the red LEDs at either end of the LED row. Each represents a cork that keeps the ball in the tube. At first, the ball on any Sun SPOT will be blue. However, if the Sun SPOTs are able to communicate with each other, they will allocate different colors for the ectoplasmic balls to avoid, as much as possible, duplication.

Pick up a Sun SPOT and tilt it right and left to make the ball move. Thanks to the red corks, the ectoplasmic ball stays on the Sun SPOT.

Now we will connect the two free-range Sun SPOTs so that the balls can move from one SPOT to the other. Press one of the buttons on a Sun SPOT. The cork above the switch will start to blink.

The cork is searching for a partner cork on another SPOT. When two corks on different Sun SPOTs both enter search mode, they quickly find each other and the corks open up. Then the two ectoplasmic balls can be poured back and forth between the Sun SPOTs.

Press one of the buttons on another Sun SPOT. The two corks should find each other, open and connect the virtual tubes.

You can pour ectoplasmic balls from one Sun SPOT to another.

Merge the Two Balls into One

The balls are a bit sticky. If two balls that come to rest in the same place, they stick to each other and merge into one ball. The color of the new ball will be the merged color of the original balls. For example, a red ball and a blue ball will merge to form a purple ball.

You can isolate any ball on a single Sun SPOT by reinstating the cork. Just press the button under the cork to break the connection and put the cork back in place. You can always open the ends again by putting two cork LEDs back into search mode. They will find each other and open a connection between the Sun SPOTs.

To restart the demo on a free-range SPOT, simply reset the SPOT (click the Control Button momentarily).

The Implementation

The Sun SPOTs use radio communication at the beginning of the demonstration to choose colors for each ectoplasmic ball. The SPOTs poll the 3-D accelerometer to determine their orientation. They use the orientation information to determine the movement of the ectoplasmic balls. Radio communication is used to determine if there is another Sun SPOT within range and if there is an open cork on that SPOT. If there is, a radio communication channel is established and used to pass the ball back and forth.

Next, we will take a look at another demonstration, the Air Text demo.


Next: Loading and Running the Air Text Demo

Back to top