Introduction: MidiTheremin With MP3 Shield

Why?

Theremins are profoundly expensive, ($500+) so this is an easy and cost effective replacement for anyone wanting to experiment with creating interactive music and music editing.

What is a theremin?

The instrument's controlling section usually consists of two metal antennas that sense the relative position of the thereminist's hands and control oscillators for frequency with one hand, and amplitude (volume) with the other. The electric signals from the theremin are amplified and sent to a loudspeaker.

Video

What is a MIDI controller?

MIDI (Musical Instrument Digital Interface) is a protocol designed for recording and playing back music on digital synthesizers that is supported by many makes of personal computer sound cards.

Supplies

  • MP3 Shield for Arduino
  • Arduino
  • Ultrasonic Distance Sensor
  • 4 Male to Female Connectors
  • Audio jack + compatible Speaker
  • Acrylic Sheet (12inx24in)
  • Drill + drill bits
  • Dremel
  • Acrylic solvent
  • 4 small magnets
  • Gorilla glue

Step 1: Create the Container

  1. Lasercut the acrylic sheet into 6 4in x 4in squares
  2. Drill two holes into the center of one box to fit the distance sensor
  3. Drill a hole the diameter of the audio jack
  4. Glue two magnets on the "base" square on the opposite corners
  5. Use the solvent to create the box, leaving the base square separate
  6. Glue the other two magnets on the same sides of the magnet on the "base" square
  7. Connect the distance sensor to the side of the box with the two holes

Step 2: Get Ready to Code!

  1. Upload your songs to the SD card and put it into the MP3 shield.

The audio must be titled 0001.mp3, 0002.mp3 etc.

2. Attach the MP3 shield to your Arduino

3. Attach the four Male to Female wires onto the distance sensor

Echo pin: 3

Trig pin: 2

Grnd pin: Grnd

Vcc pin: 5v

4. Upload your code to the Arduino!

Step 3: Input the Code Into Arduino!

#include

SoftwareSerial Geno(7,8); // mp3 shield connects to arduino unsigned char Data[10]; // unsigned char i;

int trigPin = 2; int echoPin = 3; long duration, cm, inches; int pos=0;

void setup() { delay(1000); Geno.begin(9600); Serial.begin(9600); delay(1000); SetVolume(30); //volume control pinMode(trigPin, OUTPUT); pinMode(echoPin, INPUT); }

void playTrack(int num){ //loading songs //delay(1000); Data[0] = 0x7E; Data[1] = 0x04; Data[2] = 0xA0; Data[3] = 0x00; Data[4] = 0x00 + num; Data[5] = 0x7E; Command(Data,5); play_pause(); //delay(3000); }

void SetVolume( int vol){ Data[0] = 0x7E; // start Data[1] = 0x03; Data[2] = 0xA7; // Command Data[3] = vol; // new volume Data[4] = 0x7E; // END Command(Data,5); } void play_pause(){ Data[0] = 0x7E; // start Data[1] = 0x02; // Length Data[2] = 0xA3; // Command Data[3] = 0x7E; //Mode parameter Command(Data,4); } void stop_playing() { Data[0] = 0x7E; Data[1] = 0x02; Data[2] = 0xA4; Data[3] = 0x7E; Command(Data, 4); } void Command(unsigned char *Data, int length){ for(int i=0; i

digitalWrite(trigPin, LOW); delayMicroseconds(5); digitalWrite(trigPin, HIGH); delayMicroseconds(10); digitalWrite(trigPin, LOW);

pinMode(echoPin, INPUT); duration = pulseIn(echoPin, HIGH); cm = (duration/2) / 29.1; inches = (duration/2) / 74; Serial.print(inches); Serial.print("in, "); Serial.print(cm); Serial.print("cm"); Serial.println(); delay(1700); //slow down serial updates

if (cm<10) { playTrack(1); //song length delay (1000); //pause between songs } else if ((cm>10) && (cm<60)) { playTrack(2); delay (1000); } else if ((cm>60) && (cm<200)) { playTrack(4); delay (1000); //pause between songs } else if ((cm>200) && (cm<2290)) { playTrack(5); delay (1000); //pause between songs } else if (cm>2290) { playTrack(6); delay (1000); //pause between songs }

}

Step 4: Create the Theremin!

  1. Connect the power source to the arduino
  2. Connect the aux cord through the hole and into the speaker
  3. Play!