
- Download the example code and unpack the downloaded file, which has the Phidget generic C examples.
- On Linux and OSX, open a terminal window and go to the directory where the examples are unpacked, then compile the
HelloWorld.c
example: On Linux:gcc HelloWorld.c -o HelloWorld -lphidget21
gcc example.c -o example -F/Library/Frameworks -framework Phidget21 -I/Library/Frameworks/Phidget21.framework/Headers
Visual Studio Phidgets Examples.sln
in the VCpp folder of the examples. (Since the examples were written in Visual Studio 2005, if you are opening the examples in Visual Studio 2008/2010, you will need to go through the Visual Studio Conversion Wizard to open and convert the 2005 project.) -
Run the
HelloWorld
example. On Linux (The sudo is needed for USB access for now, see "Setting udev Rules" for how to change this):sudo ./HelloWorld
On Mac:./HelloWorld
phidget21.h
andphidget21.lib
in the$(SystemDrive)\Program Files\Phidgets
. If you have these files installed in another location, please change the path to the file's location accordingly.The
HelloWorld
program will simply print out basic information for any device you plug in, and print a message upon unplugging the device. The output will look something like this:Opening... Press Enter to end Hello to Device Phidget InterfaceKit 8/8/8, Serial Number: 37299 Goodbye Device Phidget InterfaceKit 8/8/8, Serial Number: 37299 Closing...
This is a companion discussion topic for the original entry at https://community.robotshop.com/index.php/blog/show/phidgets-lesson-2-running-the-examples