Glove Instrument with Arduino and SuperCollider 

An music instrument using 4 flex sensors and an Arduino board. The readings from flex sensors are being sent to SuperCollider at real time. Firmata support is outdated on SuperCollider, so I’m using serial port instead. The signals strings are first sent to SC, separated by commas, then split function is used to separate them into array, the values in the array are assigned to variables one by one.

The data returned from flex sensor are values that is altered by its resistance. Some of the sensor was not that sensitive anymore so every mapping value should be adjusted manually.

4 buses are used in SC, 3 of them based on SinOsc(sine wave), one is based on RLPF(low pass filter). Codes in Arduino are simply reading and mapping out the value for SC to use.

Note that SC is a real time audio synthesis program, it could only possible to generate sound be initiated by starting the server and run the coding, which cannot be done automatically. It could be fun if SC behave like MaxMSP that is much more user friendly.

All codes are on Github: https://github.com/peterobbin/glove_instrument.git


Arduino code____________________________________________________________

void setup()

void loop()
int sensor, sensor2, sensor3, sensor4, degrees, degrees2, degrees3, degrees4;
sensor = analogRead(0);
sensor2 = analogRead(1);
sensor3 = analogRead(2);
sensor4 = analogRead(3);

degrees = map(sensor, 768, 853, 400, 500);
degrees2 = map(sensor2, 768, 853, 380, 500);
degrees3 = map(sensor3, 790, 853, 0.001, 20);
degrees4 = map(sensor4, 768, 853, 400, 800);

// Serial.print(“[“);




SuperCollider code _____________________________________________

arg freq = 300,freq2 = 400, freq3 =20, freq4 = 400 ;
var out;
var out2;
var out3;
var out4;
var freqMap;
out = SinOsc.ar([freq,freq4], 0,0.3);
out2 = SinOsc.ar(freq4, 0,0.3);
out3 = {RLPF.ar(LFPulse.ar([25,35].midicps, 0.15),SinOsc.kr(freq3, 0, 10, 72).midicps, 0.1, 0.1)};
out4 = SinOsc.ar(OnePole.ar(Mix(

//courtesy to Lance Putnam

Out.ar(0, out);
Out.ar(0, out2);
Out.ar(0, out3);
Out.ar(0, out4);

//a = Synth(“tones”, [“freq”,600,”freq2″,500,”freq3″,20, “freq4”,700]);


p = SerialPort(
baudrate: 9600,
crtscts: true);
a = Synth(“tones”, [“freq”,400,”freq2″,400,”freq3″,20, “freq4”,400]);
r= Routine({

var byte, str, res, tone1, tone2, tone3, tone4;
if(p.read==10, {
str = “”;
while({byte = p.read; byte !=13 }, {
str= str++byte.asAscii;
res= str.split($,).asInteger;
tone1 = res.at(0).postln;
tone2 = res.at(1).postln;
tone3 = res.at(2).postln;
tone4 = res.at(3).postln;

(“test value:”+res).postln;

a.set(“freq”,tone1,”freq2″, tone2,”freq3″,tone3, “freq4”,tone4);