SoundKnob

Materials

- 1 Piece of Styrofoam (Doughnut Shape)

- 1 Piece of Fabric (Single Strip)

- 1 Elastic Band / Tape

- 1 Potentiometer

- 1 Piezo Speaker

 

 

/* SoundKnob
 * --------
 *
 * October 4, 2011 - Pierre Tchetgen - akwerius@ischool.berkeley.edu
 */

int potPin = 0;    // select the input pin for the potentiometer
int speakerPin = 7;

int potVal = 0;

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

void loop() {
  digitalWrite(speakerPin, LOW);
 
  potVal = analogRead(potPin);    // read value from the sensor
   
  for( int i=0; i<500; i++ ) {  // play it for 50 cycles
    digitalWrite(speakerPin, HIGH);
    delayMicroseconds(potVal);
    digitalWrite(speakerPin, LOW);
    delayMicroseconds(potVal);
  }
}

SoundKnob2
SoundKnob2
0
Your rating: None