On the SPOT: David G. Simmons

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:


P5120433.JPG

Slider -- not really a sensor, but neat


P5120434.JPG

Voltage divider. Would have been nice for the J1 HOL

P5120435.JPG

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

P5120436.JPG

Force sensor. Interesting possibilities

P5120437.JPG

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:


PhidgetSPOT.png

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:



Phidget1.png

The new Sun SPOT Application Project type

Named it:



Phidget2.png

I was using the Force Sensor first

And started working on it:



Phidget3.png

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:



Phidget4.png

2 lines of code. Just 2!!

Click the 'Run' button, and start getting data from the Phidget:



Phidget5.png

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." ]


[2] Comments
Like this post? del.icio.us | furl | slashdot | technorati | digg
Comments:

You can hook any sensor up to Sentilla Perk through the
expansion connector, plus the convenience of Phidgets. You should buy
a kit and try it out. And I think they call them small computers or JCreates, not spots.

Posted by 66.166.74.139 on May 13, 2008 at 05:28 PM EDT #

Great post David!

Now, about those jumper cables (F/F)...did you corner the market? They are currently on back-order on SparkFun.

How is your I2C knowledge? Have you ever tried a connect between the SPOT and the "CMOS Camera - 1300x1040" offered by SparkFun
http://www.sparkfun.com/commerce/product_info.php?products_id=8668

Again, great post, keep them coming!

John

Posted by javapda on May 16, 2008 at 01:35 PM EDT #

Post a Comment:
Comments are closed for this entry.