Phidgets and SPOTs
Monday May 12, 2008
So the Sentilla folks were all over JavaOne this year, of course. We love those guys, and members of the Sun SPOTs Team have beers with some of the Sentilla folks at least once a month. Any rumors you hear to the contrary are false (and if you talked to the one guy in the Sentilla Booth who said Sun SPOTs were "the enemy" don't believe that, either).
That being said, I was intrigued by Sentilla's use of Phidgets. They have a plug right on the Sentilla spot for plugging in Phidgets, which makes it really easy (makes it harder to use anything BUT a phidget, of course, but I digress).
So I went back to my hotel at JavaOne and ordered up some Phidgets to play with when I got home, and lo and behold, there was a box on my doorstep when I arrived home! I ordered the Light Sensor, the Force Sensor, the Magnetic Sensor, the Slider, and the Voltage Divider. Figured that was a decent set to start with.
They come nicely packaged, with nice connector cables. Here's what they look like:

Slider -- not really a sensor, but neat

Voltage divider. Would have been nice for the J1 HOL

Light sensor. We have one built in, but a remote one is intriguing

Force sensor. Interesting possibilities

I see a door-open detector in my future
These are all 5-volt analog sensors, so I figured they should be pretty easy to deal with, and boy was I right! First thing was to hook one up. I started with the Force Sensor. I grabbed some jumper-wires, and plugged them in. Yeah, it would be nice to have a connector I could just plug a Phidget into, but I'd rather have the flexibility of using any sensor, and the lack of a specific plug isn't a hurdle. My SPOT looks like this:

SPOTs and Phidgets
And yeah, that's all it took to hook it up. So Now to write the code. I figured this would be easy, but really ...
I went to NetBeans 6.1, and clicked 'New Project', then selected a New Sun SPOT Application:

The new Sun SPOT Application Project type
Named it:

I was using the Force Sensor first
And started working on it:

Complete project made for me by NetBeans
I had to write 2 lines of code. Yes, 2. NetBeans took care of the import statement for me, as well as the try/catch block. The lines I wrote are highlighted in Red:

2 lines of code. Just 2!!
Click the 'Run' button, and start getting data from the Phidget:
Output values printed
Force readings from the force sensor show up in the console. It couldn't get any easier.
The entire process took me 2 minutes. 2 minutes!!! From there, I was able to unplug the Force Sensor and plug in the Slider and without changing the code at all get readings from it. I tried all the sensors, and without changing a single line of my code (all 2 lines of it!) I was able to read all the sensors.
I am not sure how it could get any easier. Maybe having the specific plug on the header would have made it easier, but seriously, hooking up 3 jumper wires is not that much harder than just plugging it in, is it?
Now, to find something to do with these Phidgets!
[ "Protozoa are small, and bacteria are small, but viruses are smaller than the both put together." ]












You can hook any sensor up to Sentilla Perk throug...
Great post David!
Now, about those jumper cables...