Project Members: 
Anirban Sen
Farley Gwazda
Jill Blue Lin
Kenghao Chang
Concept:
Our musical instrument is designed to be a learning and mimicking game designed for 2 players. Each player will control a set of 4 levers (we used potentiometers). Each lever will play a different instrument. We will have a tonal instrument in the form of a piezo speaker, a percussion instrument in the form of a fan-rattle, a second percussion instrument in the form of a vibrating skewer instrument, and lastly electronic output from a computer. We are having the players take turns at controlling their levers at the flip of a switch. The switch will turn off one set of controls and turn on the other set. There will also be 2 LEDs to indicate which player's turn it is to play the music. The object of the game is for one player to mimic the other player's tone, pitch, and sequence after hearing it played by the first player.
Components:
4 arduino processors
8 potentiometers
1 piezo speaker
1 DC motor
1 servo motor
2 LEDs
Code:
int potPin = 0; // select the input pin for the potentiometer
int potPin2 = 1; // select the input pin for the second potentiometer
int speakerPin = 8;
int buttonPin = 7;
int val = 0;
void setup() {
pinMode(speakerPin, OUTPUT);
beginSerial(9600);
Serial.println("ready");
}
void loop() {
int player = digitalRead(buttonPin);
digitalWrite(speakerPin, LOW);
if (player == 0){
val = analogRead(potPin); // read value from the sensor
val = val*2; // process the value a little
}else{
val = analogRead(potPin2);
}
for( int i=0; i<500; i++ ) { // play it for 50 cycles
digitalWrite(speakerPin, HIGH);
delayMicroseconds(val);
digitalWrite(speakerPin, LOW);
delayMicroseconds(val);
}
}