Input / Output Coincidence Lab Assignment

Assignment: Input / Output Coincidence Lab Assignment

Collaborators:

 

Description

The goal of this assignment was to create something that demonstrated input / output coincidence using what we've learned so far.

 

 

Components Used

The following components were used:

  • Arduino
  • Breadboard
  • Rubber band (2)
  • USB cable
  • Jumper Cable (several)
  • 10k Ohm resistor
  • Potentiometer
  • Force sensor
  • Piezo speaker
  • Cardboard disc (2)

 

Arduino Code

The following code powers a rotation and tapping-based musical instrument. A disc is turned which turns the knob on a potentiometer and adjusts the pitch, and a force sensor on the underside of the device is tapped to produce the pitch. The sound comes from a piezo speaker which lies between the potentiometer and the force sensor.

/*
* Rotation Instrument
* by Eric Mai
* October 7, 2009
* for I262 Homework
*
* Enables a potentiometer, force sensor, and piezo speaker to be used as an
* input/output concurrent instrument
*/

// Set up input and out pins as well as input variables
int potPin = 0;
int forcePin = 1;
int speakerPin = 7;
int potVal = 0;
int forceVal = 0;

void setup() {
pinMode(speakerPin, OUTPUT);
Serial.begin(9600);
}

// Read from sensors and produce a pitch according to
// the position of the potentiometer when the force sensor
//is triggered
void loop() {
potVal = analogRead(potPin);
forceVal = analogRead(forcePin);

if (forceVal > 500) {
digitalWrite(speakerPin, HIGH);
delayMicroseconds(potVal);
digitalWrite(speakerPin, LOW);
delayMicroseconds(potVal);
Serial.println(forceVal);
}
}

Video

Rotation Instrument from Eric Mai on Vimeo.

Pictures

Improvements

Improvements to the disc instrument could be made by relocating the piezo speaker to make it less muffled. Also, the instrument could benefit from a calibration of the potentiometer value to expand the instrument's tonal range.