BeatBots!

Update: Video Link! https://goo.gl/photos/qU17V29jDkocHKya6

Description:

Our instrument is a group of five robots that each have their own percussive abilities. They are 1.) a four armed tap-bot that has four servos that tap tap tap on things, 2.) a two-armed spinning bot that hits things with it’s metal hands to make noise, 3.) a rolling pinecone that makes a rumbling noise on it’s surface, 4.) a shepard with a tap-tapping staff, and 5.) a scraper-bot that uses a bristly brush to scrape things and make noise.

We mounted 4/5 of them on a turning lazy susan, with the intention of making customization possible by changing the things on which the robots are tapping. (We could rotate the lazy susan to change what object each robot was tapping on.)

Our robots are controlled by a control board with 5 pots. They control: 1.) the tempo of the music that our bots make, 2.) the pattern with which the pine cone rolls, 3.) the pattern with which the scraper scrapes, 4.) the pattern with which the shepard taps, and 5.) the speed with which the spinny bot spins.

Challenges included: 1.) Getting the robots to tap with similar patterns // with some semblance of coherent synchrony, 2.) getting the different settings of the pots to have noticeably different sounds.

Materials Used:
– 2 Arduinos
– 4 Micro-servos
– 3 normal servos
– 3D printed plastic
– lots! of jumper wires
– machine screws / nuts
– beer bottle
– 3 soda cans
– pine cone
– chopsticks
– 5 pots
– laser cut control board, pinecone eyes, lazy susan parts
– construction paper
– foam ball
– clay
– DC motor
– metal wire
– metal bolts/nuts from Dan’s bed
– wire brush
– metal marbles
– chipotle tin
– cardboard scrapey surface w/ packaging material
– diode
– resistors
– breadboard
– 3 battery packs
– rubber bands

Code:

#include <Servo.h> 

Servo myservoR;
Servo myservoRp;
Servo myservoL;
Servo myservoLp;
Servo servoLeah;
Servo servoAndrew;
Servo servoJake;
 
int deltaPot = 0;

int leahPot = 1; 
int leahBeat = 0;

int andrewPot = 2; 
int andrewBeat = 0;
 
int danielPot = 3;
int danielBeat = 0;

int jakePot = 4;
int jakeBeat = 0;

int pos = 0; // variable to store servo position 

void setup() 
{ 
 Serial.begin(9600); // setup serial
 myservoR.attach(4); //Rightmost arm from point of view of the crab
 myservoRp.attach(5); //Right-sub-prime (right arm of the left crab)
 myservoL.attach(6); //Leftmost arm from point of view of the crab
 myservoLp.attach(7);// "Left-sub-prime" (left arm of the right crab)
 servoLeah.attach(8);
 servoAndrew.attach(9);
 servoJake.attach(10);
}
 
void loop() {

 int delta = potCipher(analogRead(deltaPot))*2; //speed of the hammering
 Serial.print("delta: ");
 Serial.println(delta);

 servoAndrew.write(80); //ARMS UP!!!
 servoJake.write(80);
 servoLeah.write(80); 
 myservoR.write(80); 
 myservoL.write(100); 
 myservoLp.write(100);
 myservoRp.write(80);

 delay(1000);
 //PLAY! 
 andrewBeat = potCipher(analogRead(andrewPot));
 Serial.print("andrewBeat: ");
 Serial.println(andrewBeat);

 danielBeat = potCipher(analogRead(danielPot));
 Serial.print("danielBeat: ");
 Serial.println(danielBeat);
 
 jakeBeat = potCipher(analogRead(jakePot));
 Serial.print("jakeBeat: ");
 Serial.println(jakeBeat);

 leahBeat = potCipher(analogRead(leahPot));
 Serial.print("leahBeat: ");
 Serial.println(leahBeat);
 
 for (int i=0; i <= 400; i++){
 servoAndrew.write(getArmLoc(pos, andrewBeat)); 
 servoLeah.write(getArmLoc(pos, leahBeat)); 
 servoJake.write(getArmLoc(pos, jakeBeat));
 myservoR.write(abs(abs(80-pos)-80)); //This series SHOULD do 16th-notes, approximately... but it sounds a bit off, so my math might be wrong
 myservoL.write(abs(abs(80-(abs(pos-60)))+100)); 
 myservoLp.write(abs(abs(80-(abs(pos-80)))+100));
 myservoRp.write(abs(abs(40-pos)-80)); 
 pos += delta;

 if (pos >= 160) pos=0;
 delay(35);
 }
 delay(0);

}

int getArmLoc(int pos, int beatType) {
 if (beatType == 1) {
 return abs(abs(80-pos)-80);
 }
 else if (beatType == 2) {
 return abs(abs(40-pos)-80);
 }
 else if (beatType == 3) {
 return abs(abs(80-(abs(pos-60)))+100);
 }
 else if (beatType == 4) {
 return abs(abs(80-(abs(pos-80)))+100);
 }
}

// returns a potSection value based on the position of the pot
int potCipher(int potVal) {
 int potSection;
 if (potVal >= 0 && potVal <= 205) {
 potSection = 0; 
 }
 else if (potVal >= 206 && potVal <= 410) {
 potSection = 1;
 }
 else if (potVal >= 411 && potVal <= 615) {
 potSection = 2;
 }
 else if (potVal >= 615 && potVal <= 820) {
 potSection = 3;
 }
 else {
 potSection = 4;
 }
 return potSection;
}

Reverse Caroling

Description

We were inspired by the music of people going caroling from house to house where the visitor is the one that does the singing. But, what if we reverse who does the singing and instead have the house and person’s home do the caroling? Furthermore, what if the person who visits starts a song and then the person who’s home it is (who is answering the door) adds to that song in a duet or collaborative way? That’s what our caroling house does.

How it works:

  • A visitor walks up to the beginning of the path
  • The christmas lights light up the path
  • The visitor steps on the welcome mat
  • A song begins playing
  • The visitor presses the door bell
  • Snow falls from the gutter to create a wintery environment
  • The person who lives at the house answers the door. When they turn the doorknob, the song changes to a different octave adding to the duet.

Inputs used:

  • FSR (x3)
  • Potentiometer

Outputs used:

  • 6 LEDs
  • piezo speaker
  • servo motor to dump snow from the gutter

Materials used

  • FSR (x3)
  • Potentiometer
  • 6 LEDs
  • Piezo speaker
  • Servo motor
  • 3 Arduinos
  • 4 breadboards
  • 6 220k ohm resistors
  • 4 10k ohm resistor

Doorknob and Welcome Mat Code

// TONES ========================================== // Start by defining the relationship between
 // note, period, & frequency.
 #define C 523
 #define Db 554
 #define D 587 
 #define Eb 622
 #define E 659
 #define f 698 // Does not seem to like capital F
 #define Gb 740
 #define G 783
 #define Ab 830 
 #define A 880
 #define Bb 932
 #define B 988
 #define c_ 1046
 #define dd 1109
 #define d 1175
 #define eb 1244
 #define e 1318
 #define ff 1397
 #define gb 1480
 #define g 1568 
 // Define a special note, 'R', to represent a rest
 #define R 0
 // SETUP ============================================
 // Set up speaker on a PWM pin (digital 9, 10 or 11)
 int speakerOut = 9;
 int FSRPin = A0;
 int potPin = A1;
 int valFSR = 0;
 int valPot = 0;
 int i = 0;
 // Do we want debugging on serial out? 1 for yes, 0 for no
 int DEBUG = 1;
 void setup() {
 pinMode(speakerOut, OUTPUT);
 if (DEBUG) {
 Serial.begin(9600); // Set serial out if we want debugging
 }
 }
 // MELODY and TIMING =======================================
 // melody[] is an array of notes, accompanied by beats[],
 // which sets each note's relative length (higher #, longer note)
 int melody1a[] = {E, E, E,R,
 E, E, E,R,
 E, G, C, D, E, R,
 f, f, f,f, f, E, E,E, E, D ,D,E, D, R, G ,R,
 E, E, E,R,
 E, E, E,R,
 E, G, C, D, E, R,
 f, f, f,f, f, E, E, E, G,G, f, D, C,R, G, R }; 
 
 int melody1b[] = {B, B, B,R,
 B, B, B,R,
 B, D, G, A, B, R,
 C, C, C,C, C, B, B,B, B, D ,D,C, A, R, G ,R,
 B, B, B,R,
 B, B, B,R,
 B, D, G, A, B, R,
 C, C, C,C, C, B, B,B, B, D ,D,C, A, R, G ,R };
 
 //put melody 2a and 2b here 
 int melody2a[] = {E,R, R, R,
 f, E, Eb, E, 
 f, R, R, R, 
 Gb, G, R, R,
 R, A, B, c_, 
 d, c_, B, A, 
 G,R, R, R,
 E,R, R, R,
 f, E, Eb, E, 
 f, R, R, R, 
 Gb, G, R, R,
 R, A, B, c_, 
 d, c_, B, A, 
 G,R, R, R};
 
 int melody2b[] = {A, R, R, R,
 B, A, Ab, A,
 Bb, R, R, R, 
 B, c_, R, R,
 R, d, e, f, 
 g, f, e, d,
 c_, R, R, R,
 A, R, R, R,
 B, A, Ab, A,
 Bb, R, R, R, 
 B, c_, R, R,
 R, d, e, ff, 
 g, ff, e, d,
 c_, R, R, R};
 
// int MAX_COUNT1 = sizeof(melody1) / 2; // Melody length, for looping.
// int MAX_COUNT2 = sizeof(melody2) / 2;
 // Set overall tempo
 long tempo = 10000;
 // Set length of pause between notes
 int pause = 1000;
 // Loop variable to increase Rest length
 int rest_count = 100; //<-BLETCHEROUS HACK; See NOTES
 // Initialize core variables
 int tone_ = 0;
 int beat = 0;
 long duration = 0;
 // PLAY TONE ==============================================
 // Pulse the speaker to play a tone for a particular duration
 void playTone() {
 long elapsed_time = 0;
 if (tone_ > 0) { // if this isn't a Rest beat, while the tone has
 // played less long than 'duration', pulse speaker HIGH and LOW
 while (elapsed_time < duration) {
 digitalWrite(speakerOut,HIGH);
 delayMicroseconds(tone_ / 2);
 // DOWN
 digitalWrite(speakerOut, LOW);
 delayMicroseconds(tone_ / 2);
 // Keep track of how long we pulsed
 elapsed_time += (tone_);
 }
 }
 else { // Rest beat; loop times delay
 for (int j = 0; j < rest_count; j++) { // See NOTE on rest_count
 delayMicroseconds(duration); 
 } 
 } 
 }
 
 void playNote(int melody[]) {
 tone_ = melody[i];
 beat = 50;
 duration = beat * tempo;
 playTone();
 delayMicroseconds(pause);
 }
 
 // LET THE WILD RUMPUS BEGIN =============================
 
 void loop() {
 valFSR = analogRead(FSRPin); // read value from the sensor
 valPot = analogRead(potPin);
// int *melody = melody1; ///fix later
 if (valFSR >= 10 && valFSR < 500 ){ 
 Serial.println(valFSR);
 Serial.println(valPot);
 if (valPot < 10) {
 int *melody = melody1a;
 playNote(melody);
 } else {
 int *melody = melody1b; //move to duet
 playNote(melody);
 }
 }
 if (valFSR >= 500 ){ 
 Serial.println(valFSR);
 Serial.println(valPot);
 if (valPot < 10) {
 int *melody = melody2a;
 playNote(melody);
 } else {
 int *melody = melody2b; //move to duet
 playNote(melody);
 }
 }
// playNote(melody);
 i++;
}
// if (valFSR >= 500) { //second song
// Serial.println(valFSR);
// int *melody = melody1a;
// playNote(melody);
// i++;
// }
// if (i%60 == 0) {
// i = 0;
// }
//}

<img class="alignnone size-medium wp-image-2088" src="http://blogs.ischool.berkeley.edu/i262/files/2016/11/IMG_7584-300x225.jpg" alt="img_7584" width="300" height="225" />

The Jukebox

We created a musical instrument that focuses on manipulating MIDI files.

The basic idea of the instrument is to enable users to play musical variations of songs in almost infinite combinations of tempo, attack, decay and release.

Three potentiometers correlate to three transformations based on ASDR, which stands for attack, sustain, decay and release. We altered the attack decay and release which allowed a person using the device to create the variations.

  • Attack time is the time taken for initial run-up of level from nil to peak, beginning when the key is first pressed. We mapped 1024 values of the potentiometer to 0 – 1.5s.
  • Decay time is the time taken for the subsequent run down from the attack level to the designated sustain level. We mapped 1024 values of the potentiometer to 0-1.5s.
  • Sustain level is the level during the main sequence of the sound’s duration, until the key is released. We kept this constant at 1.5
  • Release time is the time taken for the level to decay from the sustain level to zero after the key is released. We mapped 1024 values of the potentiometer to 0-1.5s.

1100px-adsr_parameter-svg

Code:

 

/*
Logic used:
1. Set a MIDI playback with set envelope
2. Store a recorded fragment and loop over the recorded fragment
Original Authors: Multiple contributors to Minim
New authors: Neera Grover, Vivian Liu, Sandeep Pal and Ganesh Iyer
*/
import ddf.minim.*;
import ddf.minim.ugens.*;
import javax.sound.midi.*;
Minim minim;
// Sequencer objects – one for base and one for loop
Sequencer base;
Sequencer loop;
Sequence baseSequence;
Sequence backingLoop;
// For recording loops
AudioInput loopIn;
AudioRecorder loopRecorder;
// For playback
AudioOutput out;
AudioPlayer player;
import processing.serial.*;
import cc.arduino.*;
Arduino arduino;
int ledPin = 13;
int val;
int val1;
int val2;
int val3;
int val4;
void setup(){
size(512, 200, P3D);
minim = new Minim(this);
/**Connecting arduino to Processing.*/
arduino = new Arduino(this, Arduino.list()[1], 57600);
arduino.pinMode(ledPin, Arduino.OUTPUT);
arduino.pinMode(0, Arduino.INPUT); //(A0=0)
// need to set variable loopIn to something that records or reuses a sample
// right now, the issue is that it always picks up what the microphone records
loopIn = minim.getLineIn();
// getLineIn seems to be the biggest problem
// How does one use the audio generated by the computer itself as a fragment to loop over?
// enable monitoring seems to do absolutely nothing for this cause. causes feedback. some interesting sound though.
loopIn.disableMonitoring();
loopRecorder = minim.createRecorder(loopIn, currentLoop.wav);
// out is playing the minim object back to us
out = minim.getLineOut(Minim.MONO);
try
{
// get a disconnected sequencer. this should prevent
// us from hearing the general midi sounds the
// sequecer is automatically hooked up to.
base = MidiSystem.getSequencer( false );
// have to open it
base.open();
// load our sequence
baseSequence = MidiSystem.getSequence( createInput( bach.midi ) );
// put it in the sequencer
base.setSequence( baseSequence);
// hook up an instance of our Receiver to the Sequencer’s Transmitter
base.getTransmitter().setReceiver( new MidiReceiver() );
base.setTickPosition(10000);
base.setLoopEndPoint(20000);
// just keep looping
//base.setLoopCount( Sequencer.LOOP_CONTINUOUSLY );
// and away we go
// Hello Vivian!
base.start();
}
catch( MidiUnavailableException ex ) // getSequencer can throw this
{
// oops there wasn’t one.
println( No default sequencer, sorry bud. );
}
catch( InvalidMidiDataException ex ) // getSequence can throw this
{
// oops, the file was bad
println( The midi file was hosed or not a midi file, sorry bud. );
}
catch( IOException ex ) // getSequence can throw this
{
println( Had a problem accessing the midi file, sorry bud. );
}
}
class MidiReceiver implements Receiver
{
void close() {}
void send( MidiMessage msg, long timeStamp )
{
// we only care about NoteOn midi messages.
// here’s how you check for that
if ( msg instanceof ShortMessage )
{
ShortMessage sm = (ShortMessage)msg;
// if you want to handle messages other than NOTE_ON, you can refer to the constants defined in
// ShortMessage: http://docs.oracle.com/javase/6/docs/api/javax/sound/midi/ShortMessage.html
// And figure out what Data1 and Data2 will be, refer to the midi spec: http://www.midi.org/techspecs/midimessages.php
if ( sm.getCommand() == ShortMessage.NOTE_ON )
{
// note number, between 1 and 127
int note = sm.getData1();
// velocity, between 1 and 127
int vel = sm.getData2();
// we could also use sm.getChannel() to do something different depending on the channel of the message
// see below the draw method for the definition of this sound generating Instrument
out.playNote( 0, 0.1f, new Synth( note, vel ) );
}
}
}
}
class Synth implements ddf.minim.ugens.Instrument
{
Oscil wave;
Damp env;
int noteNumber;
Synth( int note, int velocity )
{
noteNumber = note;
float freq = Frequency.ofMidiNote( noteNumber ).asHz();
float amp = (float)(velocity1) / 126.0f;
wave = new Oscil( freq, amp, Waves.QUARTERPULSE );
// Damp arguments are: attack time, damp time, and max amplitude
env = new Damp( 0.01f, 0.5f, 1.0f );
// writing code for looping
wave.patch( env );
}
void noteOn( float dur )
{
// make sound
env.activate();
env.patch( out );
}
void noteOff()
{
env.unpatchAfterDamp( out );
}
}
void draw(){
val = arduino.analogRead(0);
val1 = arduino.analogRead(1);
val2 = arduino.analogRead(2);
val3 = arduino.analogRead(3);
val4 = arduino.analogRead(4);
// set the tempo
if ((val/4) < 250)) {
base.setTempoInBPM( val/4 );
}
base.setLoopCount(val2 % 10);
//set loops
//base.startRecording();
println(base.getLoopCount());
println(base.getLoopEndPoint());
println(base.getLoopStartPoint());
println(val1 * 8);
println(base.getTickPosition());
//loopcount isn’t working out
//if we get above the tick position of 20000, go back to 10000 and play again
if ((base.getTickPosition()) > 20000 (val1 * 8)) {
base.setTickPosition(10000);
//base.stopRecording();
}
// Code snippet to draw waves
background(0);
stroke(255);
// draw the waveforms
// the values returned by left.get() and right.get() will be between -1 and 1,
// so we need to scale them up to see the waveform
for(int i = 0; i < loopIn.left.size()1; i++)
{
line(i, 50 + loopIn.left.get(i)*50, i+1, 50 + loopIn.left.get(i+1)*50);
line(i, 150 + loopIn.right.get(i)*50, i+1, 150 + loopIn.right.get(i+1)*50);
}
// end code snippet to draw waves
}

The One Man Show

Description

In our endeavour to make a sonorous musical instrument, we wanted to explore the sounds different materials make on being impinged. We started with a lamp screen and brainstormed ideas around what role it could play in an interactive musical instrument. Someone suggested that it could represent a caricature of a one man band, replete with arms and legs. It sounded like a great idea and we we forged ahead with it.

We are using 4 Arduinos to control 4 Servo motors. Two of the motors are responsible for controlling the rattle and the maraca, which manifest themselves in the form of arms. The third motor controls the bobbing head, while the fourth one is responsible for impinging the tin lamp screen from the inside.

Materials used

  • Balloon
  • Cardboard
  • 4 Arduinos
  • 4 Breadboards
  • Wires
  • Pipe cleaners
  • Popsicle sticks
  • Masking tape
  • Lamp screen
  • Thread

/*
* Servo with Potentiometer control
* Theory and Practice of Tangible User Interfaces
* Nisha, Elena and Mudit are using the same code
*/

int servoPin = 7; // Control pin for servo motor
int potPin = 0; // select the input pin for the potentiometer

int pulseWidth = 0; // Amount to pulse the servo
long lastPulse = 0; // the time in millisecs of the last pulse
int refreshTime = 20; // the time in millisecs needed in between pulses
int val; // variable used to store data from potentiometer

int minPulse = 500; // minimum pulse width

void setup() {
pinMode(servoPin, OUTPUT); // Set servo pin as an output pin
pulseWidth = minPulse; // Set the motor position to the minimum
Serial.begin(9600); // connect to the serial port
Serial.println("servo_serial_better ready");
}

void loop() {
val = analogRead(potPin); // read the value from the sensor, between 0 - 1024

if (val &gt; 0 &amp;&amp; val &lt;= 999 ) { pulseWidth = val*2 + minPulse; // convert angle to microseconds Serial.print("moving servo to "); Serial.println(pulseWidth,DEC); } updateServo(); // update servo position } // called every loop(). void updateServo() { // pulse the servo again if the refresh time (20 ms) has passed: if (millis() - lastPulse &gt;= refreshTime) {
digitalWrite(servoPin, HIGH); // Turn the motor on
delayMicroseconds(pulseWidth); // Length of the pulse sets the motor position
digitalWrite(servoPin, LOW); // Turn the motor off
lastPulse = millis(); // save the time of the last pulse
}
}

Sam's code

int servoPin = 7; // Control pin for servo motor
int lightSensorPin = 0; // input for light sensor

int pulseWidth = 0; // Amount to pulse the servo
long lastPulse = 0; // the time in millisecs of the last pulse
int refreshTime = 20; // the time in millisecs needed in between pulses
int val; // variable used to store data from serial port
long lastUpdate = 0; // last update of ring

int minPulse = 500; // minimum pulse width
int maxPulse = 2250; // maximum pulse width
int lightLimit; // calibrated limit for light

void setup() {
pinMode(servoPin, OUTPUT); // Set servo pin as an output pin
pulseWidth = 1156; // Set the motor position to the minimum
Serial.begin(9600); // connect to the serial port
Serial.println("Servo control program ready");
val = analogRead(lightSensorPin);
lightLimit = val - 100; // calibrated light
}

void loop() {
val = analogRead(lightSensorPin); // read the value from the sensor, between 0 - 1024
//Serial.println(val);
// Ring bell
if (val &lt; lightLimit) {
pulseWidth = 1400;
lastUpdate = millis();
while (millis() - lastUpdate &lt;= 200) { updateServo(); } pulseWidth = 1156; } updateServo(); // update servo position } // called every loop(). // uses global variables servoPi, pulsewidth, lastPulse, &amp; refreshTime void updateServo() { // pulse the servo again if rhe refresh time (20 ms) have passed: if (millis() - lastPulse &gt;= refreshTime) {
digitalWrite(servoPin, HIGH); // Turn the motor on
delayMicroseconds(pulseWidth); // Length of the pulse sets the motor position
digitalWrite(servoPin, LOW); // Turn the motor off
lastPulse = millis(); // save the time of the last pulse
}
}

Video: https://drive.google.com/a/berkeley.edu/file/d/0B7JCq5np49-7S1hZRVIzOVJjLXc/view?usp=sharing

 

img_20161107_134025

 

Cacophony of sounds!

Team: Molly, Yifei, Olivia, Owen, Michelle

Description:

For this assignment, our team tried explore how to get motors to operate and manipulate musical instruments that we easily are able to play as humans. For this, we explored the claves, kalimba, egg shakers, bell kit, and tambourine. We first tried having servos operate the claves, but this proved to be too much of a challenge since we need to hold the claves at the point and allow them to resonate, which is something we do easily when we hold them with our hands, but not with a servo. We also looked into making noise on the kalimba using ear plugs on servos (which mimic human fingers), but the sliding motion with adjusting pressure was too difficult. We also tried using the egg shaker and a coffee cup full of beans using a DC motor or servo, but we found that the shaking beads just went towards the edge of the shaker container.

We then explored different ways to get servo motors to hit mallets on a bell kit. We noticed that if we allow for a little bit of “give” to allow a bounce on the key, rather than directly hitting the key and dampening the sound, we got a better sound. We made a “competitive game” out of the instrument: we attached two servos to the mallets and allow two player to operate pots to change the percussive nature of the mallets and instruments.

We also explored using a DC motor on a tambourine. We found if we attached tape at different diameters, we can change the amount it hits the bells. We decided to change this with a potentiometer as well.
We also decided to explore a visual medium on processing, where if you click and move the mouse – depending on how slow and fast you go, the visual component and the sound changes.

In the end we decided on having servo motors (controlled by pots) hit the bell kit and kalimba, a DC motor (controlled by pot) operate the tambourine, and a processing script on a computer. Our 4 inputs are: 2 pots for the mallets, 1 pot for the tambourine, and 1 mouse for machine. We created a fun noise game where we all contribute a part to create a cacophony of sounds!

Materials used:

  • Bell Kit
  • Tambourine
  • Kalimba
  • Computer (mouse input, processing)
  • 2x Arduino uno
  • 3x pot
  • 2x servo
  • 1x 1k resistor
  • 1x transistor
  • 1x diode
  • 1x DC motor
  • 1x battery pack

Vimeo URL to Demo video

20161106_15264320161106_152638

Code for Processing


Maxim maxim;
AudioPlayer player;
AudioPlayer player2;
void setup()
{
  size(640, 960);
  maxim = new Maxim(this);
  player = maxim.loadFile("atmos1.wav");
  player.setLooping(true);
  player2 = maxim.loadFile("bells.wav");
  player2.setLooping(true);
  player.volume(0.25);
  background(0);
  rectMode(CENTER);
}
void draw()
{
//  
}
void mouseDragged()
{
  player.play();
  player2.play();
  float red = map(mouseX, 0, width, 0, 255);
  float blue = map(mouseY, 0, width, 0, 255);
  float green = dist(mouseX,mouseY,width/2,height/2);
  
  float speed = dist(pmouseX, pmouseY, mouseX, mouseY);
  float alpha = map(speed, 0, 20, 0, 10);
  //println(alpha);
  float lineWidth = map(speed, 0, 10, 10, 1);
  lineWidth = constrain(lineWidth, 0, 10);
  
  noStroke();
  fill(0, alpha);
  rect(width/2, height/2, width, height);
  
  stroke(red, green, blue, 255);
  strokeWeight(lineWidth);
  
  //rect(mouseX, mouseY, speed, speed);
  line(pmouseX, pmouseY,mouseX, mouseY);
  //brush1(mouseX, mouseY,speed, speed,lineWidth);
  //brush2(mouseX, mouseY,speed, speed,lineWidth);
  //brush3(mouseX, mouseY,speed, speed,lineWidth);
  //brush4(pmouseX, pmouseY,mouseX, mouseY,lineWidth);
  //brush5(pmouseX, pmouseY,mouseX, mouseY,lineWidth);
  //brush6(mouseX, mouseY,speed, speed,lineWidth);
  //brush7(pmouseX, pmouseY,mouseX, mouseY,lineWidth);
  player.setFilter((float) mouseY/height*5000,mouseX / width);
  //player2.setFilter((float) mouseY/height*5000,mouseX / width);
  
  player2.ramp(1.,1000);
  player2.speed((float) mouseX/width/2);
}
void mouseReleased()
{
  //println("rel");
  player2.ramp(0.,1000);
        
}

Code for 2x Servos for bell kit, controlled by pot


/*
 * Servo with Potentiometer control
 * Theory and Practice of Tangible User Interfaces
 * October 11 2007
 */
int servoPin1 = 4;      // Control pin for servo motor
int servoPin2 = 5;
int potPin1 = A1;      // select the input pin for the potentiometer
int potPin2 = A2;
int pulseWidth1 = 0;    // Amount to pulse the servo
int pulseWidth2 = 0; 
long lastPulse = 0;    // the time in millisecs of the last pulse
//long lastPulse2 = 0;
int refreshTime = 20;  // the time in millisecs needed in between pulses
int val1;               // variable used to store data from potentiometer
int val2;
int minPulse = 500;   // minimum pulse width
void setup() {
  pinMode(servoPin1, OUTPUT);  // Set servo pin as an output pin
  pinMode(servoPin2, OUTPUT);
  pulseWidth1 = minPulse;      // Set the motor position to the minimum
  pulseWidth2 = minPulse;
  Serial.begin(9600);         // connect to the serial port
  Serial.println("servo_serial_better ready");
}
void loop() {
  val1 = analogRead(potPin1);    // read the value from the sensor, between 0 - 1024
  if (val1 > 0 && val1 <= 999 ) {
    pulseWidth1 = val1*2 + minPulse;  // convert angle to microseconds
    
    Serial.print("moving servo to ");
    Serial.println(pulseWidth1,DEC);
  
  }
  updateServo1();   // update servo position
  
  val2 = analogRead(potPin2);
  if (val2 > 0 && val2 <= 999 ) {
    pulseWidth2 = val2*2 + minPulse;  // convert angle to microseconds
    
    Serial.print("moving servo to ");
    Serial.println(pulseWidth2,DEC);
  
  }
  updateServo2();   // update servo position
 
}
// called every loop(). 
void updateServo1() {
  // pulse the servo again if the refresh time (20 ms) has passed:
  if (millis() - lastPulse >= refreshTime) {
    digitalWrite(servoPin1, HIGH);   // Turn the motor on
    delayMicroseconds(pulseWidth1);  // Length of the pulse sets the motor position
    digitalWrite(servoPin1, LOW);    // Turn the motor off
   lastPulse = millis();           // save the time of the last pulse
  }
}
void updateServo2() {
  // pulse the servo again if the refresh time (20 ms) has passed:
  if (millis() - lastPulse >= refreshTime) {
    digitalWrite(servoPin2, HIGH); 
    delayMicroseconds(pulseWidth2);
    digitalWrite(servoPin2, LOW); 
    lastPulse = millis();           // save the time of the last pulse
  }
}

Code for DC motor controlled by Pot


/*
 * one pot fades one motor
 * modified version of AnalogInput
 * by DojoDave <http://www.0j0.org>
 * http://www.arduino.cc/en/Tutorial/AnalogInput 
 * Modified again by dave
 */

int potPin = 0;   // select the input pin for the potentiometer
int motorPin = 9; // select the pin for the Motor
int val = 0;      // variable to store the value coming from the sensor
void setup() {
  Serial.begin(9600);
}
void loop() {
  val = analogRead(potPin);    // read the value from the sensor, between 0 - 1024
  Serial.println(val);
  analogWrite(motorPin, val/4); // analogWrite can be between 0-255
}