Teensy Lab

You should be all set with this part, but if not, for starters, you’ll need to install the Teensy Loader, Arduino, and Teensyduino.  The first three videos posted here walk you through the process of installing the software, getting the Teensy and Arduino talking and getting your first LED to blink.

Next up, we’ll want to read some sensor data *into* Arduino from the Teensy.  To do this, in the Arduino IDE, go to File –> Examples –> Basic –> AnalogReadSerial.  Get a mini-potentiometer (or pot, for short) and connect the center pin to Teensy’s A0 pin (analog 0).  Then connect either side of the pot to ground and to Vcc (+5V).


Load the sketch onto the board.  Then, to see what you’ve got coming in from the board, in Arduino go to Tools –> Serial Monitor.  Then turn the knob on the pot to see how the values coming in begin to change.

Next up, lets make the pot control a piezo speaker.  You can follow the adafruit tutorial, here.  This will work fine with the pot, but if you prefer to swap out the pot for a photoresistor, no problem.  Now lets focus on getting the Teensy to talk to Max/MSP.

First, you will need to install Maxuino, and make sure that Max can find it.  I put mine in my Max folder –> Packages.  There are newer versions, but I like the arduino_test patch included Maxuino 007.  I recommend starting with this.

Second, you will need to load the standard firmata onto your board.  In Arduino, find it under Files –> Examples –> Firmata –> Standard Firmata.  Loading this onto your board lets your Teensy talk to other software, besides the Arduino IDE — not just Max/MSP.

Open arduino_test, select the correct serial port (to find out what that is, in Arduino, check Tools–>Serial Port).  Be sure to open the port by clicking on the port message in the gray box, and then choose which analog input to listen to in the red box.  Move your pot to make sure the values are being read in.  Note that they have been scaled between 0 and 1.  Assuming all is well, now you can send the values coming from that input and receive them elsewhere to control different parameters (frequency, amplitude, etc.).  Set up a simple oscillator and try controlling the pitch with the incoming values.  I’ve made a beautiful looking example with an extra toggle, below, on the side of the original sketch.  Note the  send over by the orange box.  It is connected to the values coming in from A0.

Screen shot 2014-02-07 at 12.44.16 AM

Be sure all your number objects controlling the pitch are flonums or you won’t get what you’re expecting.   This includes putting a float in the multiplier object. Otherwise you will create a patch that won’t recognize any of the floats–and since all of the decimal values are < 1, and 1 is the highest potential value, the pot will only turn on and off the sound, rather than affecting the frequency.

Of course you can also clean things up by encapsulating/abstracting this so that you don’t have to have the entire arduino_test patch in your patch.

Now that you have a working prototype, consider adding a second sensor – try something new!  You could also experiment with newer versions of Maxuino.  However, when you’re testing out sensors, it never hurts to start out firmly in Arduino territory, and test them one at a time and then together.  Then you can worry about communicating with Max/MSP, later.

Hope this helped!

One thought on “Teensy Lab

Leave a Reply

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

WordPress.com Logo

You are commenting using your WordPress.com 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