PCOMP final: Audio and potentiometer slider

Last thursday I spent about 12 hours trying to make the potentiometer based on Kit of No Parts but with copper tape and mylar.  I made my own illustrator file based on the design and cut it out with the laser cutter and then wired it up.  Everything worked until I had it all together and then I couldn’t get a connection between the mylar and Arduino.  In the example they use semi-conductive ink, which is probably what I needed.  My failed attempt:

I was all pissed and was like I’m going to have to buy stupid expensive slider potentiometers online.  But then I went home and slept for a while and then in the morning I came in and tried a new design based on this site and had something working in a couple of hours.  I sanded a groove into a piece of wood, laid copper tape into it, then taped mylar over it, and was able to get values by pressing the mylar with my finger or a pencil.

 

[yframe url=’http://www.youtube.com/watch?v=NBuZAi7pxkQ’%5D

That was cool when that worked, so I moved on to test some of the audio.  I set up the Arduino with Minim to simply play an audio file if the volume is up above 1 (-35) and to change the volume.  I borrowed code from Robbie that was used in his candle media controller project.

and my audio sample: erhu1

Here’s the code:


import ddf.minim.*;

import processing.serial.*;

Minim minim;
AudioPlayer erhu;
WaveformRenderer waveform;

Serial port;
float volume = 0;

void setup() {
  size(100, 100);

  println(Serial.list());
  String portName = Serial.list()[0];
  port = new Serial(this, portName, 9600);
  port.bufferUntil('n');

  minim = new Minim(this);
  erhu = minim.loadFile("erhu1.mp3", 512);
  erhu.loop();
  waveform = new WaveformRenderer();
  erhu.addListener(waveform);

}

void draw() {
  background(0, 255, 0);
  waveform.draw();
  erhu.setGain(volume);
  if (volume > -44) {
    erhu.play();
  } else if (volume < -44){
    erhu.pause();
  }

}

void serialEvent (Serial port) {
  String myString = port.readStringUntil('n');
  if (myString != null) {
  }
  myString = trim(myString);
  int sensors[] = int(split(myString, ','));
  for (int i = 0; i < sensors.length; i++) {
    volume = map(sensors[0], 0, 1023, -45, 45);
  }
  println(volume);
}

//void stop() {
//  erhu.close();
//  minim.stop();
//  super.stop();
//}
Advertisements

Author: owen ribbit

poop

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s