Introduction to Phidgets - CMPT 898


What are Phidgets?

Phidgets are a set of easily programmable hardware components produced by Phidgets, Inc. Its name stands for "Physical Widgets" and it was first introduced at ACM UIST in 2001.

While not as mainstream as technologies like Arduino, Phidgets are still quite popular, and you'll find some really cool stuff ranging from robots to the most popular coffee roasters in Calgary.

This is the original UIST video when Phidgets were first introduced. Keep in mind this was back in the year 2001!

back to top

Cool! Where can I buy them?

Phidgets can be purchased in many electronics stores. They can also be purchased through their website or through RobotShop.

back to top

What are the advantages / disadvantages of Phidgets?

As Bill Buxton once said: "Everything is best for something and worse for something else". You'll come across a lot of technologies that have different pricing and capabilities.

When to use Phidgets

  • If you don't care about your physical user interface being (1) clunky and (2) always attached to the computer.
  • If you want to quickly be able to prototype different electronic components.
  • If you are looking for a platform that supports multiple languages such as C# and Java.

When not to use Phidgets

  • If you have budget limitations, Phidgets can be pricier due to their modularization.
  • If you want your physical user interface to be stand-alone (i.e. not be hooked up to a computer).
back to top

Types of Phidgets

I classify Phidgets into three categories. The reason for this is that it affects how you instantiate the different components. My categories are (1) independent input, (2) interface-kit input and (3) actuators (output).

Independent Input

These input devices do not require a Phidgets interface kit in order to operate. This means they can be plugged into the USB port directlty.

Interface-Kit Input

The interface kit is a USB device that takes in multiple analog inputs. For example, if you were to use a force sensitive resistor (FSR), you can plug up to 8 FSR modules into it. Modules like the joystick require two sockets - one for the x and one for the y.

Actuators (Output)

Actuators refer to motors such as servos or DC motors.

back to top


  1. Download the drivers for your programming environment - Phidget Drivers Page
  2. Once the system is installed, you will have access to the Phidget Control Panel. This is a great tool that lets you know which Phidgets are plugged in, what the sensor readings are, and also allows you to change values for output, such as moving a servo motor. This is what the control panel looks like
  3. In your code import Phidget21.NET.dll or phidget21.jar
back to top

Code Snippets

The Phidgets API has a pretty consistent way of initializing and operating Phidgets. The focus is on making them event-driven. This is particularly important for the input.

Importing the Phidget Library

In C#

using Phidgets; // to get access to Phidgets objects
using Phidgets.Events; // to enable events

In Java

import com.phidgets.*; // to get access to Phidgets objects
import com.phidgets.event.*; // to enable events

Working with an Accelerometer (Independent Input)

In C#


// creating an accelerometer instance
Accelerometer accel = new Accelerometer();

// events that get triggered when the accelerometer is detected
// as being attached, detached, or when there is an error
accel.Attach += new AttachEventHandler(OnAccelAttached);
accel.Detach += new DetachEventHandler(OnAccelDetached);
accel.Error += new ErrorEventHandler(OnAccelError);

// event that triggers when the acceleration changes
accel.AccelerationChange += new AccelerationChangeEventHandler(OnAccelChanged);

// start reading for the accelerometer data;

// wait for the accelerometer to be attached (prevent errors)

Accelerometer changed event handler

public static void OnAccelChanged(object sender, AccelerationEventArgs e)
   // For the indexing - x is 0, y is 1, z is 2
   Console.WriteLine("Axis " + e.Index + " :: Acceleration Value " + e.Acceleration);

Working with the InterfaceKit


InterfaceKit interfaceKit = new InterfaceKit();;
interfaceKit.SensorChange += new SensorChangeEventHandler(OnSensorChanged);

InterfaceKit changed event handler

public static void OnSensorChanged(object sender, SensorChangeEventArgs e)
   Console.WriteLine("Index " + e.Index + " :: Value " + e.Value);

This is almost the same in Java -

interfaceKit.addSensorChangeListener(new SensorChangeListener()
   public void sensorChanged(SensorChangeEvent se)
      //Insert your code here

Accessing an InterfaceKit value in run time:

// value for the interface kit sensors is from 0 to 1000
int forceValue = interfaceKit.sensors[0].Value;

Note: some Phidgets should be calibrated. For example, the force sensor will rarely go from 0 to 1000. Instead you will find that some go from 100 to 600, so make sure you calibrate from the minimum and maximum values. This can be quickly seen on the Phidgets control panel!

Working with Actuators (Output) - Motor

When working with servo motors keep in mind that there are two core components. First is the servo controller, which controls one or more servo motors (depending on which module you have). The second component is the motor itself.

// Phidgets refers to the servo controller as a Servo
Servo servoController = new Servo();
// The actual servo motor is called ServoServo
ServoServo motor = new ServoServo();;
motor = servoController.servos[0];

To change the value of a servo motor, you have to give it a value between 0 and 180. Just like with interfaceKit sensors, motors have different thresholds and may not reach the full range. There are also some edge conditions that will make the motor struggle, so make sure to check that on the control panel.

motor.Position = 180;

Note: make sure you close your Phidgets when you finish


Otherwise your Phidgets will keep running even after you exit the code. I burned a couple of motors in the past because of that.

back to top

Other Resources

back to top