Categories
EDUC 587

Light Theremin

This project follows the Light Theremin tutorial from the Arduino projects book. In the first few seconds of the video, the sensor calibrates, then begins making noise. You can also see my flick my desk lamp on and off to further show the effect without my hand blocking it. All in all, a pretty simple project this week, but it has a fun (and slightly ear-splitting) end product!

Here’s the code–unlike last week, I followed the exact instructions in the project book.

int sensorValue;
int sensorLow = 1023;
int sensorHigh = 0;

const int ledPin = 13;

void setup() {
  pinMode (ledPin, OUTPUT);
  digitalWrite(ledPin, HIGH);

  while (millis() < 5000) {
    sensorValue = analogRead(A0);
    if (sensorValue > sensorHigh) {
      sensorHigh = sensorValue;
    }
    if (sensorValue < sensorLow) {
      sensorLow = sensorValue;
    }
    digitalWrite(ledPin, LOW);
  }
}

void loop() {
  sensorValue = analogRead(A0);
  int pitch =
    map(sensorValue,sensorLow,sensorHigh, 50, 4000);
    tone(8,pitch,20);
    delay(10);
}

Leave a Reply

Your email address will not be published. Required fields are marked *