We closed this forum 18 June 2010. It has served us well since 2005 as the ALPHA forum did before it from 2002 to 2005. New discussions are ongoing at the new URL http://forum.processing.org. You'll need to sign up and get a new user account. We're sorry about that inconvenience, but we think it's better in the long run. The content on this forum will remain online.
IndexProgramming Questions & HelpElectronics,  Serial Library › Easy Phidgets to Processing IFKit Library!
Page Index Toggle Pages: 1
Easy Phidgets to Processing IFKit Library! (Read 1379 times)
Easy Phidgets to Processing IFKit Library!
Jun 19th, 2006, 4:28am
 
Well, after a day of messing about, I finally got a class together to control a PhidgetsInterfaceKit (www.phidgets.com) with Processing. Simply!

Why would you want to do this?
Because you can now go into processing, create a new file, and type the following:
Code:

p=new PhidgetsIFK();
p.output(7,true);
delay(500);
p.output(7,false);

and have an LED blink on for half a second!

For centuries Phidgets have confounded the wise and intrigued everyone. Now anyone can use them, simply with processing! This library/class should support all PhidgetInterfaceKits, although I have only tested it with the IFKit 8/8/8.

Here's a demo program/needed files:
http://staronesw.com/Phidget.zip
(it wants an LED hooked up to digital output #7 and/or a pushbutton on digital input #7. If you're new to electronics, remember to ground both of them, and if the LED doesn't work, you've got the legs plugged in backwards)

And a brief instruction set:
You will need to have phidgetsWebServices running, see phidgets.com for downloads (it comes with the Phidgets libraries in most cases).
Operating specific instructions:
On Mac OS X:
open Terminal (Applications/Utilities/Terminal) and enter:
/usr/bin/phidgetwebservice pass &

On Windows:
C:\Program Files\Phidgets\PhidgetWebServiceManager.exe”.
Set it to port 5001 (or change the port below), and password "pass".
Click start.

On Linux:
Open the directory "phidgetwebservice", run make in that directory to make "phidgetwebservice" and then enter
/usr/bin/phidgetwebservice pass

Functions: Code:

To use this class:
PhidgetsIFK p;  //usually put this before void setup()
p=new PhidgetsIFK();  //usually put this in void setup()

To get analogue sensor input values:
float p.sensor(int which);  //get sensor value (0.0 to 1.0 range)
boolean p.sensorChanged(int which); //check if it's changed

To get digital input values:
boolean p.input(int which);  //get input value
boolean p.inputChanged(int which); //check if it's changed

To get digital output values:
boolean p.output(int which);  //get output value
void p.output(int which, boolean what); //set the output value


To go from a normal project to a Super Phidgets Enhanced Project (tm)  you will need to copy the code folder and the file PhidgetsIFK.pde from the example into the code folder of your project. The code folder contains phidgets.jar which is from phidgets.com.

Now, you might be wondering "why do I need this? Won't the Java library work fine in Processing." Well, yes it will, and does (my "library" is simply a Processing class itself), but that is quite ridiculously hard and poorly [read: nearly un]documented.
You might also be wondering "What is this?" This is a Processing class that allows you to very easily control digital outputs and digital/analogue inputs from your computer via your USB port. For those of us who don't have a Parallel port, this is probably the easiest way to control our electronics projects from our computers.
Or the biggie "What about the physical side?". My demo program tries to use a pushbutton/toggle switch and an LED, both of which are easier found at Radio Shack, or somewhere else. I'll post some simple schematics and pictures/videos at some point. Here's my demo program controlling the LED with the mouse button: http://www.staronesw.com/LEDandProcessing.mov
(sorry about the mess of wires, only 2 are in use, but the rest are screwed into the IFKit and they're rather useful to keep in place. Also, this is from a webcam so the quality is rather pathetic)

Btw, I would appreciate any feedback, comments, suggestions, or results of your experiments!

Page Index Toggle Pages: 1