Group 10:
- Osman Khwaja (okhwaja)
- (av)
- Igor Zabukovec (iz)
- Junjun Chen (junjunc)
Prototype 1: The Buzz Drum
The piezo element picks up knocks (of varying loudness), causing the buzzer to buzz.
This prototype uses the Piezo sensor and a buzzer. When the piezo sensor senses a vibration, like when we knock on the surface, it sends a signal to the Arduino which then causes the buzzer to buzz. So, essentially, when you drum it, it buzzes.
Prototype 2: The Flex Buzz
The flex sensor changes the frequency of the buzzer tone.
This prototype uses the buzzer and the flex sensor. When the sensor is flexed, the tone of the buzzer was changed. In theory, it sounded like a good idea. In reality, we didn’t have much control over the flex sensor’s output values and the change in the buzzer was not as apparent as we had hoped.
Final Prototype/Prototype 3: DJ Breadboard
Our last prototype uses a potentiometer, accelerometer, and a button all located on the breadboard to control the output sound from the computer.
We thought this would be really cool because, using a couple of sensors, we could control many different aspects of the sound. The potentiometer controls frequency of the synthesized sound (just a triangle wave and a sine wave together). The x and y axis of the accelerometer control the left-right panning of the triangle and sine wave, respectively. Lastly, the button fades the sound in or out. We used Arduino and Processing’s Sound Module (Minim)
Final System Parts:
- Arduino + USB cord + Breadboard
- Wires
- 1 10 kohm resistor
- 1 ADXL335 accelerometer
- 1 Button
- 1 Rotary Potentiometer
Instructions:
Connect the accelerometer to the Arduino (Vin to A0, 3Vo to A1, Gnd to A2, Yout to A4, Xout to A5). Note that we don’t connect Zout to the Arduino, as we won’t be using the Z axis, and we need A3 for the rotary pot. Connect the button to digital pin 2 (as well as 5V and the 10kohm resistor to ground). Connect the rotary pot to A3 (and 5V and ground). Run the following code in Arduino and Processing
Arduino Code:
// these constants describe the pins. They won’t change:
const int groundpin = A2; // analog input pin 2
const int powerpin = A0; // analog input pin 0
const int xpin = A5; // x-axis of the accelerometer
const int ypin = A4; // y-axis
// const int zpin = A3; // z-axis
const int pot = A3;
const int button = 2;
void setup()
{
// initialize the serial communications:
Serial.begin(9600);
// Provide ground and power by using the analog inputs as normal
// digital pins. This makes it possible to directly connect the
// breakout board to the Arduino. If you use the normal 5V and
// GND pins on the Arduino, you can remove these lines.
pinMode(groundpin, OUTPUT);
pinMode(powerpin, OUTPUT);
pinMode(button, INPUT);
pinMode(pot, INPUT);
digitalWrite(groundpin, LOW);
digitalWrite(powerpin, HIGH);
establishContact();
}
void loop()
{
if (Serial.available() > 0) {
// print the sensor values:
double b = (digitalRead(button) == HIGH) ? 1 : 0;
double a = analogRead(pot) / 1023.0;
double x = (343.0 – analogRead(xpin)) / (413.0 – 343.0);
double y = (341.0 – analogRead(ypin)) / (411.0 – 341.0);
Serial.print(x);
// print a tab between values:
Serial.print(“,”);
Serial.print(y);
Serial.print(“,”);
Serial.print(b);
Serial.print(“,”);
Serial.println(a);
}
}
// Establish contact with processing.
void establishContact() {
// Send an initial string until connection made
while (Serial.available() <= 0) {
Serial.println(“0,0,0”);
delay(300);
}
}
Processing Code:
import ddf.minim.*;
import ddf.minim.signals.*;
import controlP5.*;
import processing.serial.* ;
Serial port;
Minim minim;
AudioOutput out;
SineWave sine;
TriangleWave tri;
ControlP5 gui;
public float triAmp = 0.5;
public float triPan = 0;
public float triFreq = 880;
public float sinAmp = 0.5;
public float sinPan = 0.5;
public float sinFreq = 440;
void setup()
{
size(512, 400, P3D);
minim = new Minim(this);
// get a stereo line out from Minim with a 2048 sample buffer, default sample rate is 44100, bit depth is 16
out = minim.getLineOut(Minim.STEREO, 2048);
// 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, out.sampleRate());
// set the portamento speed on the oscillator to 200 milliseconds
sine.portamento(200);
// add the oscillator to the line out
out.addSignal(sine);
// create a triangle wave Oscillator
tri = new TriangleWave(880, 0.5, out.sampleRate());
tri.portamento(200);
out.addSignal(tri);
// set up the gui
gui = new ControlP5(this);
gui.addKnob(“triFreq”, 40, 5000, 10, 250, 60);
gui.addKnob(“triAmp”, 0, 1, 0.5, 85, 250, 60);
gui.addKnob(“triPan”, -1, 1, 0, 165, 250, 60);
gui.addKnob(“sinFreq”, 40, 5000, 280, 250, 60);
gui.addKnob(“sinAmp”, 0, 1, 0.5, 355, 250, 60);
gui.addKnob(“sinPan”, -1, 1, 0, 430, 250, 60);
/* Get serial data. */
println(“Available serial ports:”);
println(Serial.list());
port = new Serial(this, Serial.list()[0], 9600);
port.bufferUntil(‘\n’); /* Read in one line at a time. */
delay(1000);
}
void draw()
{
background(0);
gui.draw();
stroke(255);
// draw the waveforms
}
void stop()
{
out.close();
minim.stop();
super.stop();
}
void serialEvent(Serial port) {
String myString = port.readStringUntil(‘\n’); /* Read in a line. */
myString = trim(myString); /* Remove leading / tailing whitespace. */
float sensors[] = float(split(myString, ‘,’));
if (sensors.length == 4) {
tri.setFreq(sensors[3] * 1000);
tri.setAmp(triAmp);
tri.setPan(sensors[0]);
sine.setFreq(sensors[3] * 1000);
sine.setAmp(sinAmp);
sine.setPan(sensors[1]);
if (sensors[2] < 0.5) { tri.setAmp(0); sine.setAmp(0); } if (sensors[2] > 0.5) {
tri.setAmp(1);
sine.setAmp(1);
}
// Print out sensor values:
for (int sensorNum = 0; sensorNum < sensors.length; sensorNum++) {
print(“Sensor ” + sensorNum + “: ” + sensors[sensorNum] + “\t”);
}
println();
}
port.write(“A”); // Send byte to get more data from Arduino program.
}