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

Loading and Running The Air Text Demo

 
 

Now, lets try downloading another demo to a Sun SPOT. That will give you an idea of how to download Java programs to a Sun SPOT

Compile, Deploy and Run the Demo

  1. Within NetBeans, navigate to the Sun SPOT directory and then the Demos subdirectory. On a windows workstation, the absolute file path is usually C:/Program Files/Sun/SunSPOT/Demos. Open the project which is in the [SunSPOTdirectory]/Demos/AirText directory. Make sure "Open as Main Project" is selected, then click on the "Open Project Folder" button.

A screenshot of the NetBeans 'Open Project' dialog box.  The AirText project is selected from the Demo directory.

NetBeans projects are simply folders with a NBProject folder in them. You can look at any of the files with ordinary editors.

  1. Clean and build this project. You can do this either by right-clicking on the project (control-click for a Macintosh) and selecting "Clean and Build Project" as shown below...

A screenshot of NetBeans.  The AirText demo has been selected and right-clicked.  A pop-up menu is displayed and the cursor is over an option that reads 'Clean and Build Project.'

or you can select the "Build" menu from the main menu bar and select "Clean and Build Project" from that menu:

A NetBeans screenshot. The AirText project has been selected.  The cursor has selected 'Build' from the main menu bar and is over an option in the drop down menu which is labeled 'Clean and Build Main Project.'

After you command the system to clean and build the project, you should see an output panel open at the bottom of the NetBeans window. The output panel will show the output from the compile operation. This text should end with "BUILD SUCCESSFUL" and the time it took to build the object code.

  1. Connect a free range Sun SPOT to the USB cable. Reset (or turn on) the free-range Sun SPOT by tapping the SPOT control button. The LED to the right will flash green during the synchronization.
  1. Select the project in the project window, right-click on it (control-click on a Macintosh), and select "deploy" from the pop-up menu. This will create a jar file from the compiled code and start to transfer it to the Sun SPOT.

A NetBeans screenshot.  The cursor has right-clicked the AirText project and is positioned over an item in the pop-up menu.  The item is labeled 'Deploy to Sun SPOT.'.

The download operation will then pause with the words "SPOT client starting... (please reset SPOT on port COMn) [waiting for reset]". Just tap the control button to get the download to proceed. The LED to the right will flash green as the Sun SPOT attempts to synchronize with the host workstation.

If the deploy operation is successful, the output at the bottom of the NetBeans window will end with something like this:

A Netbeans screenshot.  The AirText project is still the main project, but the focus is now on the a console window occupying much of the bottom half of the NetBeans display.  The console is titled 'Output - AirText (jar-deploy)'.  The console window displays text from a command.  The portion visible says 'Download operation completed successfully.  Writing configuration (1081 bytes) to COM5.  Download operation completed successfully. Exiting.'  The second 'Download operation completed' message is circled.

If the words "Download operation completed successfully" do not appear, then the Sun SPOT is probably not synchronized with the host workstation. Try resetting the Sun SPOT again.


Troubleshooting: If you get output that looks like this:A NetBeans screenshot.  The console window shows output from a command, ending with the words 'Build failed.'  Above this, the words 'Unhandled exception encountered: COM5 is in use.' are circled.

If you see output that says "COM5 is in use" or "Port COMn unavailable..." that means that some other process is using the Sun SPOT and the deploy script can't write to it until that process is done with it. To fix this problem, you need to terminate the other Sun SPOT-related processes. Go to the upper left panel of the NetBeans window, where there are three tabs: Projects, Files and Runtime. Click on the Runtime tab.

A NetBeans screenshot. The upper left panel is shown.  There are three tabs in this panel: Project, Files, and Runtime.  The Runtime tab is circled and the cursor is pointing to it.

Expand the "Processes" node. It will display a list of running processes.

A NetBeans screenshot. Of the three tabs in the upper left panel, the Runtime tab has been selected.  The panel shows three items at the top level.  These are Servers, Processes and Databases.  The Processes item has been selected and expanded.  One process is show and it has the label 'AirText(run)'. This process has been selected and the cursor is pointing to it.

Right clicking on a process will give you the option of terminating that process. Terminate all the processes. Click on the project tab again and try deploying the demo to the Sun SPOT again.


When you have successfully deployed the code to the Sun SPOT, turn the Sun SPOT off and disconnect the Sun SPOT from the USB cable. Now tap on the control button to start the demo.

Note: Nothing will happen happen after the reset. The LEDs on the sensor board will be off until you follow the directions below.

The Effect

This is a drawing of someone holding a Sun SPOT in their right hand, with the eDemo board facing towards the viewer and the radio fin to the viewer's left.  The hand is moving the SPOT very rapidly from left to right and the LEDs are blinking as it moves.  It has the effect of spelling out 'SPOT' in the air as the LEDs blink on and off.

This demo displays better in a darkened room, but anywhere that you can see the main string of eight LEDs will work. Hold the Sun SPOT up, with the radio antenna fin out to the left. Swing the Sun SPOT very quickly, as quickly as you can, from left to right and back again a few dozen times. Swing wide and fast. Go for a back and forth distance of one, two, or even three feet.

The Sun SPOT will sense the acceleration and will turn the LEDs on and off in such a way that your eyes will see words painted in the air by the Sun SPOT. The words will say "Hi!...This...is a...Sun...SPOT".

The next step is to modify the Air Text program and load the changed program on to a Sun SPOT.


Next: Changing the Air Text Demo

Back to top