Max And Phidgets Disco LED

This project will introduce you to how Max works with Phidgets Interfaces. This tutorial will give you the basics so you can develop more complex projects on your own. The possibilities are countless.


  • Phidget Interfacekit 8/8/8 (like the 1018_2)
  • Phidgets Rotation Sensor (like the 1116_0) and sensor cable
  • 5 LEDs (any colour)
  • Breadboard
  • Connector Wires

You’ll need both the Phidgets drivers and Max6 installed (and working) on your computer.

Download the Phidgets drivers and libraries.

Setting Up The Hardware

MaxPhidgetsExample-HardwareSetup.jpgConnect the Rotation Sensor to analog input 0 using the sensor cable. Connect the LEDs to digital outputs 0 through 4, as shown in the image. The cathode (shorter wire) is connected to the ground and the anode (longer wire) is connected to the digital output.

Connecting Phidgets to Max

Phidgets has help files and examples for most of their hardware. If you’re starting from scratch, you can create an object called “Phidget[device name]” and then bring up the help file to view all the different controls. Every Phidget device will take in “getVersion”, “getSerial” and “getStatus” messages, which are great ways to quickly check that your device is talking to Max.

For this tutorial, you can download and open the MaxPhidgetExample project to get started.


In the MaxPhidgetExample you’ll see a few different parts:

Phidget Interface

In box 2 lies the PhidgetInterfaceKit object. You can send the “getVersion”, “getStatus” and “getSerial” messages to check that your device and Max are talking (if they’re not, make sure that no other programs are connecting to your device). The start and stop messages will start and stop polling your device for input, and you can also set the sample rate, (100ms is the default and will work just fine for this example).

Reading Input

Underneath the PhidgetInterfaceKit object, in box 3, we “unpack” the inputs. We’re just going to be needing analog input 0 for this example, that’s where the rotation sensor is connected. We’re going to feed that data through some math expressions and then use that to set the rate of a metronome that will control the speed that the lights blink at. Over on the far right, you can also see we’re going to change the duration that the lights stay lit with this value so they stay on longer when the speed of them is slower.

Sending Output

That takes us to box 4. We’re going to light up each LED sequentially with a counter and gate. Then, using a subpatch called onoff, blink the light on and off. “onoff” simply sends two bangs to the toggle to turn it on and then off after a specified time. We then “pak” that message and send it to the Phidget Interface Kit for being output.

System Control

In box 1, at the very beginning, the “start disco” button sends signals to both the interface kit (to start or stop it from sampling the input) and also to the metronome (to start or stop signals from being sent to the lights).

Displaying Input

Finally, box 5 visually displays the input signal.


Making it Work

Lock the patch. Click the “start disco” toggle. Turn the rotation sensor knob and watch the LEDs increase or decrease in blinking frequency. The disco dial in the Max patch window displays the input being received.

That’s the basics of connecting input and output to a Phidget Interface and using it in a Max patch. There are countless things you can do with the tools provided in Max and any of the Phidgets products. Have fun playing around and creating cool stuff.


Phidgets make your ideas real. Reliable sensors, motor controllers, relays and more connect computers and technology to the real world. Applications include robotics, data acquisition, monitoring, automation, testing, teaching, art and interactive design. Simply plug in the device and write a program with the help of our robust API. Applications can be developed on Windows, OS X, Linux (including Raspberry Pi), iOS and Android. It's easy for programmers to get started using their favourite language: Android Java, Applescript, C/C++, C#, Cocoa, Delphi, Flash AS3, Java, LabVIEW, MATLAB, Max/MSP, Python, Ruby, Visual Basic.NET, Visual Basic 6.0, Visual Basic for Applications, Visual Basic Script, Visual C/C++/Borland.NET and Flowstone. Phidgets is an established company with an excellent reputation for making reliable products that last, at a very reasonable price, that get the job done. There's always stock, so you won't have to wait to get started on your project. Plus, you'll always be able to get support from a team of knowledgable engineers. With Phidgets, you'll get your project up and running in no time!

Tagged with: , , , , , , , ,
Posted in How-Tos

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )


Connecting to %s

%d bloggers like this: