Phidgets Lesson 2: Running the Examples

Phidgets Lesson 2   Phidgets supports a variety of languages, but before you start programming, you'll need to get the library for the language you like working in, which can be found on the language pages on Phidgets.com. While you're there, you'll also find the code examples and an in-depth API. The C library comes with the drivers you installed in Phidgets Lesson 1. So, for this lesson, we'll run those examples. This should get you started and ensure the Phidgets are working. You can refer to the resources provided by Phidgets to run examples in the other languages.
  1. Download the example code and unpack the downloaded file, which has the Phidget generic C examples.
  2. 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
    On Mac:
      gcc example.c -o example -F/Library/Frameworks -framework Phidget21 -I/Library/Frameworks/Phidget21.framework/Headers
    On Windows, you can use Visual Studio to open the examples. To load all projects in Visual Studio, go to File → Project → Solution, and open 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.)
  3. 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
    On Windows, in Visual Studio, click on Debug → Start Debugging. The projects, by default, try to find the phidget21.h and phidget21.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. Running a Phidgets Example in Visual Studio 2005 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...
Examples are provided for most Phidget devices. You can compile and run each with the process enumerated above. Phidgets supports a variety of languages. If you're not programming in C, you'll need to get the library for the language you're using before you start. The libraries can be found on the language pages on Phidgets.com. When you're there, you'll also find the code examples and an in-depth API. Now, it's on to writing your own code. You can use the examples as a guide for your project. In later lessons, we'll explore some of the functions, data structures and classes to give you an idea of all that can be done with Phidgets.
Flag this post

Thanks for helping to keep our community civil!


Notify staff privately
It's Spam
This post is an advertisement, or vandalism. It is not useful or relevant to the current topic.

You flagged this as spam. Undo flag.Flag Post