Introduction: Mega Vinyl Player

Mega vinyl player (by Dries, Laurens & Sven) - Interaction Design @ Mad-Faculty (Genk)
Arduino-powered project.

This large vinyl player powered by Arduino plays sounds depending on the higher / lower parts on the 'vinyl' (wooden plank). The difference in height is measured by a potentiometer. You're free to tweak the project as you wish.

IMPORTANT: This project was a matter of trial-and-error. Not everything might be perfect and it's more of an experiment. Feel free to change the process/code as you please. Follow your intuition! :)

Video:

http://www.youtube.com/watch?v=neUZw9xFHv4&feature=youtu.be

Materials required:
- Tape
- Arduino jumper wires (quite a few)
- Enough wooden planks to work with

Tools required:
- Illustrator
- Arduino (+ Processing)
- Tools to solder
- Milling machine
- Lastercutter

Process:
1. Start with making a design for your vinyl player. In Illustrator you can design a circle with tracks in it. In our project, we've chosen for two tracks. In these tracks, you design higher/lower parts. Don't forget to cut a circle in the middle - Here you can place a pipe which gives the support to make your box with the potentiometers turn around the mega vinyl player.

2. After you've made your flat 2D design, use a large milling machine to cut out your mega vinyl player. To give you an idea of an size: We used 120x120 centimeters.

3. Okay, now a difficult part: Design a way to make your box with potentiometer turn around the mega vinyl player and support itself. For example: We used a beam which is put around the pipe. At the end of the beam we glued a wheel.

4. Measure the length between your two tracks. This amount gives you an idea how to place your potentiometers, and how large your box will be. Now design a box with your two potentiometers sticking out of the box. In the box you have the Arduino and your jumper wires, together with a motor shield and your USB-cable. We use the motor shield to make the box together with beam move of course.

5. Bring it all together! When you've glued your potentiometer in the box, connect a piece of wood to it and add some weight on it, so that it always drops when there's a difference in height (see the pictures). You can use the lasercutter to make your box, piece of wood, ... 

6. When you think you've got everything. Time to program!

Code:
Note: The code has been tweaked constantly. So there are a lot of stuff in the comments. Feel free to play around with it! ^_^

ARDUINO:
---------------

const int
PWM_A   = 3,
DIR_A   = 12,
BRAKE_A = 9,
SNS_A   = A0;
boolean flag = false;
boolean flag1 = false;

void setup() {
  // Configure the A output
  pinMode(BRAKE_A, OUTPUT);  // Brake pin on channel A
  pinMode(DIR_A, OUTPUT);    // Direction pin on channel A

  // Open Serial communication
  Serial.begin(9600);
}

void loop() {

  // Set the outputs to run the motor forward

  digitalWrite(BRAKE_A, LOW);  // setting brake LOW disable motor brake
  digitalWrite(DIR_A, LOW);   // setting direction to HIGH the motor will spin forward

  analogWrite(PWM_A, 255);     // Set the speed of the motor, 255 is the maximum value

  // read the input on analog pin 0:
  int sensorValue = analogRead(A4);
  int sensorValue2 = analogRead(A5);


//  Serial.println(sensorValue);
  if(sensorValue > 700 && flag == false){
    Serial.print("1");
    flag = true;
  }
  if(sensorValue < 700){
    flag = false;
  }
  if(sensorValue2 > 160 && flag1 == false){
    Serial.print("2");
    flag1 = true;
  }
  if(sensorValue2 < 160){
    flag1 = false;
  }
  // int sensorValue2 = analogRead(A4);
  // print out the value you read:
  /* Serial.print(sensorValue);
   Serial.print(" + "); */

  //Serial.print(sensorValue);
  //Serial.print(',');
  //Serial.print(sensorValue2);
  //Serial.println();

}

PROCESSING:
---------------------

import processing.serial.*;
import ddf.minim.*;
import themidibus.*; //Import the library

MidiBus myBus; // The MidiBus

AudioPlayer[] music=new AudioPlayer[20];

int[] numbers = new int[20];

Minim minim;
int i = 0;
int a = 0;
int b = 0;
boolean play = false;
int teller =0;
int teller2 =0;
Serial myPort;
int test;

Boolean firstContact = false;

void setup() {
  println(Serial.list());
  myPort = new Serial(this, Serial.list()[4], 9600);

  MidiBus.list();

  numbers[0] = 67;
  numbers[1] = 71;
  numbers[2] = 62;
  numbers[3] = 67;
  numbers[4] = 62;
  numbers[5] = 71;
  numbers[6] = 71;
  numbers[7] = 62;
  numbers[8] = 83;
  numbers[9] = 67;
numbers[10] = 67;
numbers[11] = 83;
numbers[12] = 72;
numbers[13] = 83;
numbers[14] = 67;
numbers[15] = 67;
numbers[16] = 83;
numbers[17] = 81;
numbers[18] = 81;
numbers[19] = 67;

/* int pitch = int(67);
  int pitch = int(71);
  int pitch = int(62);
  int pitch = int(67);
  int pitch = int(62);
  int pitch = int(71);
  int pitch = int(71);
  int pitch = int(62);
  int pitch = int(83);
  int pitch = int(67);*/

  minim=new Minim(this);
  music[0]=minim.loadFile("1.mp3", 1024);
  music[1]=minim.loadFile("2.mp3", 1024);
  music[2]=minim.loadFile("3.mp3", 1024);
  music[3]=minim.loadFile("4.mp3", 1024);
  music[4]=minim.loadFile("5.mp3", 1024);
    music[5]=minim.loadFile("6.mp3", 1024);
  music[6]=minim.loadFile("7.mp3", 1024);
  music[7]=minim.loadFile("8.mp3", 1024);
  music[8]=minim.loadFile("9.mp3", 1024);
  music[9]=minim.loadFile("10.mp3", 1024);
  music[10]=minim.loadFile("11.mp3", 1024);
  music[11]=minim.loadFile("12.mp3", 1024);
  music[12]=minim.loadFile("13.mp3", 1024);
  music[13]=minim.loadFile("14.mp3", 1024);
  music[14]=minim.loadFile("15.mp3", 1024);
    music[15]=minim.loadFile("16.mp3", 1024);
  music[16]=minim.loadFile("17.mp3", 1024);
  music[17]=minim.loadFile("18.mp3", 1024);
  music[18]=minim.loadFile("19.mp3", 1024);
  music[19]=minim.loadFile("20.mp3", 1024);
  myBus = new MidiBus(this, -1, "Java Sound Synthesizer"); // Create a new MidiBus with no input device and the default Java Sound Synthesizer as the output device.
}

void draw() {
  int channel = 0;

  int test = numbers[teller];

  int pitch = int(test);
  int velocity = 127;

   while (myPort.available() > 0) {
    int inByte = myPort.read();
    println(inByte);
   if(inByte == 50){
     println("test");
    myBus.sendNoteOn(channel, pitch, velocity); // Send a Midi noteOn
  delay(200);
  myBus.sendNoteOff(channel, pitch, velocity);


    teller++;


   }
   if(teller == 9){
   teller =0;
   }

   if(inByte == 49){
     println(teller2);
    myBus.sendNoteOn(channel, pitch, velocity); // Send a Midi noteOn
  delay(200);
  myBus.sendNoteOff(channel, pitch, velocity);
    teller2++;

   }
    if(teller2 == 7){
   teller2 =0;

  }
  }


}

//void serialEvent(Serial myPort){
// String myString = myPort.readStringUntil('\n');
// if(myString != null){
// 
//  myString = trim(myString);
//   
//  int sensors[] = int (split (myString, ','));
// 
//  int a = sensors[0];
//  int b = sensors[1];
//print(a);
//print(" ");
//print(b);
//print(" ");
//print(play);
//println();
//
// 
//  if (a > 695 && play == false){
//       music[i].play();
//        i++;
//
//       play = true;
//
//      }
// 
//      
//      if (a < 700){
//       play = false;
//      }
//    
//     
//    }
//   
//}
//  
void noteOn(int channel, int pitch, int velocity) {
  // Receive a noteOn
  println();
  println("Note On:");
  println("--------");
  println("Channel:"+channel);
  println("Pitch:"+pitch);
  println("Velocity:"+velocity);
}

void noteOff(int channel, int pitch, int velocity) {
  // Receive a noteOff
  println();
  println("Note Off:");
  println("--------");
  println("Channel:"+channel);
  println("Pitch:"+pitch);
  println("Velocity:"+velocity);
}
void delay(int time) {
  int current = millis();
  while(millis() < current+time) Thread.yield();
}