Luis Estades
Published

Project #6 Light Theremin

Make a light based Theremin using a phototransistor to make sound, that can be affected by how much light hits, making different pitches.

BeginnerShowcase (no instructions)1 hour755
Project #6 Light Theremin

Things used in this project

Hardware components

Arduino UNO
Arduino UNO
×1
Breadboard (generic)
Breadboard (generic)
×1
Arduino phototransistor
×1
Buzzer, Piezo
Buzzer, Piezo
×1

Software apps and online services

Arduino IDE
Arduino IDE

Story

Read more

Schematics

Fritzing Sketch

Code

Light Theremin

Arduino
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 = sensorHigh;
      }
      if (sensorValue < sensorLow)
      {
        sensorLow = sensorValue;
      }
  }
  digitalWrite(ledPin, LOW);
}

void loop() {
  // put your main code here, to run repeatedly:
  sensorValue = analogRead(A0);
  int pitch =
    map (sensorValue, sensorLow, sensorHigh, 50, 4000);

  tone (8, pitch, 20);
  delay(10);
}

Credits

Luis Estades
13 projects • 1 follower
Contact

Comments

Please log in or sign up to comment.