----------------------------------------------------------------------------------------------------------
Hello, this is my first post at Geek Pink, and the first time I write an entire post in English. Please, feel free to make any corrections.
This tutorial was originally written in Portuguese (which you can read here) on my personal blog.
---------------------------------------------------------------------------------------------------------
Currently, there are some alternatives for those who want to tinker
with hardware that are more interesting and less complicated than what most of us have seen at an engineering course - one that I
can mention is the Lego Mindstorms kit - you can create robots, put light and/or pressure sensors, use engines, and program it all with a simple (but limited) programming IDE using blocks provided with the kit, or programming in C and pass the program through infrared
to the Lego robot.
Another solution is the Bug Labs, which offers a basic kit and
"accesories" to make more interesting projects, like a
camera of 2MP, GPS, a base to connect USB gear, motion
sensor, accelerometer ... the problem, again, is the price: $ 250 for
the base, and 50 to $ 80 for extra modules. But it brings a SDK to help
in development, and is open-source.
Also, there's Arduino, which is also open-source. It's the less expensive solution because it's mostly a pre-build micro-controller on a board with a developer enviromment. It's a solution for more experienced circuit designers because it's not so easy to use more advanced gear with it - even if it's easier than building your own board, of course.
And the solution I'm going to talk about is the Sun one: Sun SPOTS. Basically, they are small hardware that you can program in Java, because it
runs a virtual machine. It has accelerometers, light sensors, analog and digital buttons, etc..
Again, prices are a problem: $ 750 for the base and its accesories.
There is a promotional discount for American students, leaving it at a $ 300 price tag. For
some time, they were offering kits to students who submited proposals of interesting projects - a friend of mine got a kit this way. This promotion is no longer valid, but I still have a chance to get a kit, as a Sun Campus Ambassador who's doing a course in Control and Automation Engineering.
To get a kit
I need to make an interesting proposal to use the Sun Spots. And to do
that, I must know it better, to learn what it can do.
And I can do this not by just reading the site, but actually programming and testing in Sun Spots! Not in a real one, of course, but in an emulator
provided by Sun.
Because I love to write tutorials, I will try to write about my learning experience.
Installing the Emulator
First of all, you must have Sun Java JRE. If you program in Java, you have that, no need tp worry. More specific instructions can be
found here, according to the operating system you use.
With the required Runtimes, all you need do to is go to the page of the Sun Spot Manager and download the application.

Run
it with Sun Java WebStart (your system probably will know the
extension and open it with this program, anyway), read it all (I'm sure you
will do this ...), scroll down to the end, click next, next
... if you want, create a shortcut to the Sun Spot Manager on your
desktop for easier access when you need it later.
It will check if you have NetBeans. If you don't, install it
as suggested, and Apacje Ant. This helps a lot when developing, trust me.
Moreover, there aren't any secrets to install this - it will check the requirements of the system, suggest
installing something that is required and you don't have ... if you read at least the minimum
(you know, those messages that usually appear with an exclamation ), you should not encounter problems here. But if you find any,
post it in the comments section and I will try to help, of course.
If you did everything right, double-click the shortcut that is on your
desktop and it will open the Sun SPOT Manager. The
part that interests us is the Solarium

It is here that we have access to the Sun SPOT Emulator - click the
small button written "Solarium" in the lower right corner and it will open the
emulator (and where you can see the actual Sun SPOTS that you
have connected to your PC).
Go to the "emulator" menu and select the option "new virtual spot". You will see an image of a small Sun Spot on your screen:
Okay, this is the emulator. By right-clicking it you will see the "Deploy MIDlet bundle," which is where
you will select the program you did to test on the sun SPOT ... which leads
us, of course, to the next step: how to do a program for the Sun SPOT?
Developing for the Sun SPOT with NetBeans
If you installed NetBeans with the Sun SPOT Manager, you already have
the necessary plugins. But this is not the case for many people, so
let's see how to install the necessary plugins. First, you must
download this plugin and install it.
To install this plugin, open NetBeans and go the "Tools" menu -> Plug-ins.
On the Tab "downloads", select "add plug-ins" and select the plugin you just
downloaded. After you install it, go to the available plug-ins tab, and
reload the catalog. Install the plugins in the Sunspot category that appear:

Then, create a new project in the Java category, of Sun Spot Application type:
You will see that it creates a default class,
StartApplication.java, which has all the "imports" needed to boot
your Spot - in fact, this is a program that you can test on your
emulator. It doesn't do much, though - it comes down to blinking a light until you press a button.
The code for this is in startApp ():

The first line uses a method to get an instance of Switch 1, the first light is
placed in a slightly red color on the second line and then it starts a
loop that runs while Switch 1 is "open" (a switch closes a circuit when it
is pressed, so the term "open" means an open circuit, ie, a button not pressed): turns a led on, waits a quarter of a second, turns off the led, waits a second and restarts the process.
When the switch is pressed, the program leaves the loop and
notifyDestroyed is called to end the program (which calls destroyApp, that does nothing but make sure that all LEDs are turned off in this case).
To build the program and test it, you
should build it, right-clicking on the project and selecting "build".
This will generate a jar in the "suite" of your project.
Now, let's go to the last step: test your "Hello, Sun Spot world." project.
Testing the Project on the Emulator
Remember what I said about how we would test the application in
Solarium? Return to the Solarium, where you created the Virtual Spot,
right-click on it in "Deploy MIDlet bundle" and then select the jar
file that you created.
To test, right-click on the SPOT,
"MIDlet Run" -> "StartApplication". Okay, now you have an amazing sun spot that... ... flashes a LED!!
If you click
again with the right button and then "Display Sensor Output" ->
Internal frame, you will also see the values of the sensors (you can
also change them through this interface), as below:
And here we finish the first part of the tutorial. I hope that in the next part
we learn things more interesting than flashing LEDs, right?