Arduino theremin concert

One of the arduino tutorials was for a theremin. With a few modifications I was able to properly express my sophisticated musical abilities.

Enjoy!

Arduino code follows (prolly doesn’t make TOO much sense without the wiring schematic… if there’s interest I’ll put up a picture).

int sensorValue;
int sensorLow=1023;
int sensorHigh=0;
const int ledPin=13;
void setup(){
  pinMode(ledPin,OUTPUT);
  digitalWrite(ledPin,HIGH);
  Serial.begin(9600);
  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);
  Serial.print(sensorValue)
  Serial.print("  ")
  Serial.print(pitch)
}

Leave a Reply