A set of headphones rigged with an accelerometer that detects the motion of the user’s head and converts that motion data into MIDI data via an Arduino microprocessor. The MIDI then triggers percussion sounds in a software synth on the computer, which feeds the audio signal back to the user wearing the headphones.
Liesje, Tim and I finished our midterm project for Physical Computing tonight. Our original concept was the Voodoo Bear, but after managing to break a couple sensors and a vibration motor in the building process, we decided go with a slightly different concept.
In this week’s Physical Computing lab, we learned how to power a DC motor using a transistor. I wired up my Arduino and motor following the schematic in the lab documentation exactly:
The connectors on the DC motor are extremely fragile. I managed to break one off accidentally, so I had to borrow Tim’s motor. I haven’t had the best of luck lately with components. While working on our midterm project, the Voodoo Bear, we managed to break a flex sensor and a stretch sensor today.
In any case, I got the DC motor to work:
With the addition of a potentiometer and the additional code provided, I now have a potentiometer-controlled spastic DC motor!
In other news, we managed to complete most of the construction on the Voodoo Bear today. We put two servomotors into the bear. One makes the bear blink and the other one makes the bear’s arm wave. The servos and other components are affixed to a flexible “skeleton” inside the bear that is made out of thick ethernet cables.
I worked with Tim and Liesje yesterday on our Physical Computing midterm, the Voodoo Bear, which is a bit like Frankenstein’s monster, built from the shell of a Build-a-Bear and various wires, sensors and other components. The bear will move in reaction to human actions on a connected Processing program or through triggering sensors built into the bear. Click on the schematic below for details. Still very much a work in progress, so I’ll save full the explanation for later.
In my spin on the lab, I hooked up 2 potentiometers through the Arduino to control the frequency and panning of a sine wave in Processing that is manifested on screen and as audio. I don’t know why I chose red and blue for the sine waves. Maybe I’ve been watching too much TV coverage of the presidential campaign. In any case, the effect is that of a sine wave of doom or a poser theremin.
To get Processing to play sound, I used the Minim library. I basically poached some example code from the Minim site and tweaked it so the sound responds to analog ins from the Arduino instead of mouseX and Y in the original sketch.
I hope to use more exciting sensors later on to make it more expressive and musical when I get back from fall break next week, but it took me awhile to tweak the software side of things and the computer store was already closed by the time I got around to this. Here it is in action:
import processing.serial.*;Â Â Â Â // import the Processing serial library import ddf.minim.*; import ddf.minim.signals.*;
Serial myPort;Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â // The serial port AudioOutput out; SineWave sine; int sensors[] = new int[2];
int passX; int passY;
void setup(){ myPort = new Serial(this, Serial.list()[0], 9600); myPort.bufferUntil(‘\n’); size(512, 200); // always start Minim before you do anything with it Minim.start(this); // get a line out from Minim, default sample rate is 44100, bit depth is 16 out = Minim.getLineOut(Minim.STEREO, 512); // create a sine wave Oscillator, set to 440 Hz, at 0.5 amplitude, sample rate 44100 to match the line out sine = new SineWave(440, 0.5, 44100); // set the portamento speed on the oscillator to 200 milliseconds sine.portamento(200); // add the oscillator to the line out out.addSignal(sine); passX = 0; passY = 0; }
void draw() { background(0,50); stroke(255); // draw the waveforms for(int i = 0; i < out.left.size()-1; i++) { stroke(#FF0000); //left is red line(i, 50 + out.left.get(i)*50, i+1, 50 + out.left.get(i+1)*50); stroke(#0023FC); //right is blue line(i, 150 + out.right.get(i)*50, i+1, 150 + out.right.get(i+1)*50); } float freq = map(passY, 0, 1023, 1500, 60); sine.setFreq(freq); // pan always changes smoothly to avoid crackles getting into the signal // note that we could call setPan on out, instead of on sine // this would sound the same, but the waveforms in out would not reflect the panning float pan = map(passX, 0, 1023, -1, 1); sine.setPan(pan); }