This project tutorial 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.
You’ll need both the Phidgets drivers and Max6 installed (and working) on your computer.
Phidgets drivers, libraries and installation instructions can be found in the Cycling '74 Toolbox
Connect 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.
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. Media:MaxPhidgetsExample.zip
In the MaxPhidgetExample you’ll see a few different parts:
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).
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.
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.
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).
Finally, box 5 visually displays the input signal.
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.