teaching machines

Tiangle

December 30, 2017 by . Filed under music, public.

Instrument #2 in my foray into Pure Data and Arduino is the tiangle (sic). We’ll use a potentiometer to slur the emitted pitch up and down. When musicians play notes with no break between, we call that a tie. Our instrument will tie together different angles or rotations of the potentiometer. Thus, tiangle.

Technically, ties are sequences of the same note linked together. We abuse the term when we talk about tying together different pitches. Sorry. I liked the name, and the abuse stands.

Potentiometers generally have three pins. The outer pins connect to the voltage source and ground, in whatever order, and the inner pin gives a reading proportional to the rotation of the potentiometer. Here are the connections we need to make in our Arduino setup:

In the Arduino sketch, we constantly use analogRead to read the inner pin, which will be a value in the range [0, 1023]. We’ll shimmy (rangemap) this value into a byte in [0, 255] and send it along the serial port. Here’s what I wrote, with a slight delay to lessen the traffic on the serial port:

#include "Arduino.h"

const int POTENTIOMETER = 2;

void setup() {
  Serial.begin(9600);
}

void loop() {
  int value = analogRead(POTENTIOMETER);
  Serial.write(value / 4);
  delay(50);
}

The final result sounds like this: