The Tiangle, Part II

This post is part of a series of notes and exercises for a summer camp on making musical instruments with Arduino and Pure Data.

We have an Arduino setup that allows the player to crank a knob to produce numbers on the serial port. Now it’s time to add the music. In this exercise, we create a Pure Data patch that reads the single-byte readings and feeds them to an oscillator.

Pure Data Interpreter

Here’s our first go at this patch:

The comport object is a bit like the Serial Monitor of the Arduino development environment. It reads data from the serial communications port at a speed of 9600 bits per second. But instead of printing the numbers it reads, it sends them along through its outlet. The three boxes above comport and connected to its inlets are messages. When you click on the devices message, you get a list of devices connected to the serial port. open 1 connects to the first device in that list. close 1 disconnects from that device.

Let’s build it. First, unplug the Arduino from your computer and close the Serial Monitor. Two things can’t read from the serial port at the same time.

Then recreate this patch in Pure Data. The only new idea here are the messages. Use Put / Message to add those.

Once you’ve got your patch, leave Edit Mode. Reconnect the Arduino, click devices, find your Arduino (it’s probably device 1), and hit open. Crank that potentiometer and let the sound fly!

Right? It probably doesn’t do what you want. The problem is that Serial.println in the Arduino sketch sends the reading not as a number, but as text. Instead of sending 207, for example, it sends characters 2, then 0, and then 7 all as separate bytes. Let’s fix this. First hit the close 1 message to free up the Arduino from Pure Data. Then change Serial.println to Serial.write, which sends each reading as a single byte. Verify and upload the sketch, and then return to Pure Data. Hit open 1 and see if it sounds better.


After you get sound working, answer the following questions on a piece of scratch paper.

  1. What direction of turn increases the frequency? Clockwise or counter-clockwise?
  2. What’s the least frequency that you can hear?
  3. Try “crooning” or singing along with the tiangle. What’s a frequency that you can match?


Leave a Reply

Your email address will not be published. Required fields are marked *