L2: Bop It

Group 15: Prakhar Agarwal (pagarwal@), Gabriel Chen (gcthree@), and Colleen Carroll (cecarrol@)

Initial Prototypes:

Our first attempt at making an instrument out of a frisbee. One prong has a flex sensor underneath so the prong can be bent to control pitch.

http://www.youtube.com/watch?v=eaklr8EyHkU

Source Code: See source code for final design.

Prototype 2 uses the same base to control different elements. This time we have added a button to make the tone play only when it is pressed, as well as a rotary potentiometer for volume control.

http://www.youtube.com/watch?v=xs3a8tc6fVE

Source Code: See source code for final design.

For the last prototype, we tried something completely different, and came up with a pretty good Halloween or horror movie music maker.

http://www.youtube.com/watch?v=WSFCYuvStzk

Source Code:

/*

ADXL3xx

Reads an Analog Devices ADXL3xx accelerometer and communicates the

acceleration to the computer. For AdaFruit ADXL335 breakout board.

Modified from code at

http://www.arduino.cc/en/Tutorial/ADXL3xx

The circuit:

analog 0: Vin

analog 1: 3vo

analog 2: ground

analog 3: z-axis

analog 4: y-axis

analog 5: x-axis

test pin is hanging off the edge :)

created 2 Jul 2008

by David A. Mellis

by Tom Igoe

modified 19 Feb 2013

by Rebecca Fiebrink

This example code is in the public domain.*/

// 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

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);

digitalWrite(groundpin, LOW);

digitalWrite(powerpin, HIGH);

}

void loop()

{

// print the sensor values:
Serial.print(analogRead(xpin));

// print a tab between values:

Serial.print("\t");

Serial.print(analogRead(ypin));

// print a tab between values:

Serial.print("\t");

Serial.print(analogRead(zpin));

Serial.println();

int xfreq = analogRead(xpin);
int yfreq = analogRead(ypin);
int zfreq = analogRead(zpin);

tone(8, xfreq+yfreq+zfreq);
// delay before next reading:

delay(100);

}

Description of Final Design:

Our group built a an instrument that can be played by 1-3 people. Our inspiration was essentially creating a musical Bop-It. Each end of the three-prong instrument has a different control over the sound. We liked that the instrument can be played by a range of people, our project can be the basis for a solo, duet, or trio piece. The device is limited in the range of interactions. While there are multiple useful controls, each sits on the unmoving object. With one more iteration we may have included the accelerometer to make a moving object. Additionally, we can only play within one octave because of limitations with the size of the Overall, we found the final product a fun and interesting challenge for multiple players.

In this instrument, as mentioned before, each prong of the frisbee controls a different musical aspect of the sound that the buzzer plays. One has a button to control when the tone is made. A second has a rotary potentiometer to control volume. The third will have a sliding potentiometer that determines the pitch.

http://www.youtube.com/watch?v=6ZTAg1WNUTs

Source Code:

#include "pitches.h"
/* FSR simple testing sketch.

Connect one end of FSR to power, the other end to Analog 0.

Then connect one end of a 10K resistor from Analog 0 to ground

For more information see www.ladyada.net/learn/sensors/fsr.html */

int slidePin = 0; // the FSR and 10K pulldown are connected to a0

int buttonPin = 9;

int slideReading; // the analog reading from the FSR resistor divider

int buttonReading;

void setup(void) {

// We'll send debugging information via the Serial monitor

Serial.begin(9600);

}

void loop(void) {

slideReading = analogRead(slidePin);

Serial.print("Analog reading = ");

//Serial.println(slideReading); // the raw analog reading

Serial.println(slideReading);

int freq;
if (slideReading < 125) {
freq = NOTE_C7;
}
else if (slideReading < 250) {
freq = NOTE_D7;
}
else if (slideReading < 375) {
freq = NOTE_E7;
}
else if (slideReading < 500) {
freq = NOTE_F7;
}
else if (slideReading < 625) {
freq = NOTE_G7;
}
else if (slideReading < 750) {
freq = NOTE_A7;
}
else if (slideReading < 875) {
freq = NOTE_B7;
}
else {
freq = NOTE_C8;
}
/* buzzer in 8th pin */
while (true) {
tone(8, freq);
buttonReading = digitalRead(buttonPin);
if (buttonReading == 0) {
noTone(8);
break;
}
}
}

Materials:

Three-Prong Frisbee
Buzzer
10K Resistor
Potentiometer
Button
3 Small (Red) Breadboards
1 Large Breadboard
Arduino
Electrical Tape
Wire

Instructions:

Firstly, wire the buzzer on the large breadboard and hook it up to the Arduino.
Set the button in one of the small breadboards and connect it to the buzzer so that the buzzer will now only play when the button is pressed.
In one prong, cut a hole and place the button through it. Tape it in place.
Next, set the rotary potentiometer in another small breadboard. You will wire this to the buzzer, replacing the resistor in the buzzer circuit with the rotary pot.
Cut a hole in another prong and place the rotary pot though it. Tape it in place.
Lastly, wire the sliding potentiometer on a small breadboard and attach the output to an input pin on the arduino. The code below shows how we map the potentiometer readings to buzzer frequencies.
Cut a hole in the frisbee on the last prong and slip the sliding pot through it. Tape it in place. You now have a musical bop-it!