Project tutorial
Light Sensitive Theremin

Light Sensitive Theremin © GPL3+

In this project, I am going to demonstrate how to make a theremin-like instrument that makes weird spacey sounds.

  • 2,453 views
  • 0 comments
  • 3 respects

Components and supplies

About this project

Learn about theremins at: https://en.wikipedia.org/wiki/Theremin

Light Sensitive Resistors

A light dependent resistor or LDR is a light controlled variable resistor. The resistance of a LDR decreases with increasing light intensity. However on the idIoTware shield, the LDR is wired such that with a higher light intensity we get a higher Analog Voltage on Pin A3.

Mode of Operation

The theremin is a musical instrument that makes spacey sounds as you move your hand near it by responding to changes in capacitance.

In this example we are going to use LDR sensor to make weird spacey sounds. When we wave our hand over the LDR the light intensity changes. This data is then captured by Arduino through a voltage divider. We set the frequency according to the light value by using a map and tone functions in the Arduino IDE to generate specific frequency.

Configuring idIoTware Shield

Once you upload the code, test the theremin by waving your hand up and down over the sensor. You will hear different sets of tones.

No more connecting LEDs to breadboard and messy wiring. With the idIoTware shield the sky's the limit.

Code

lighyt_thereminArduino
const int ldrPin = A3;
const int buzzerPin = A1;

// variable declaration
int value;  // sensor value
int low;    // low sensor value calibration
int high;   // high sensor value calibration
// LED pin alert calibration
int led = 13;
 
void setup() 
    {
      pinMode (buzzerPin, OUTPUT);
      pinMode (led, OUTPUT);
      // turn LED on
      digitalWrite(led, HIGH);
      // calibration for the first 3 seconds after program runs
      while (millis() < 3000) 
            {
              // record the maximum sensor value
              value = analogRead(ldrPin);
              if (value > high) 
                 {
                   high = value;
                 }
              // record the minimum sensor value
              if (value < low) 
                 {
                   low = value;
                 }
            }
      // turn LED off
      digitalWrite (led, LOW);
    }
 
void loop() 
     {
       //read the input from A0 and store it in a variable
       value = light();
       // map the sensor values to a frequency range 50 Hz - 4000 Hz
       int pitch = map(value, low, high, 100, 4000);
       // play the tone for 20 ms on buzzer pin 8
       speaker(pitch, 20);
       // wait for a moment
       delay(10);
     }
     
//function to calculate potentiometer value
int light()
   {
    int val = analogRead(ldrPin);
    return val;
   }

void speaker(unsigned int frequency, unsigned long duration)
            {
              tone(buzzerPin, frequency, duration);
            }     
     

Schematics

idiotware-shield

Comments

Similar projects you might like

Controlling LED light intensity using smartphone light senso

Project tutorial by Nikola Travis

  • 2,995 views
  • 0 comments
  • 4 respects

Hand Glove Light Theremin

by Hamlet

  • 3,036 views
  • 0 comments
  • 11 respects

Real Theremin Using Open.Theremin Shield for Arduino

Project showcase by Urs Gaudenz

  • 18,560 views
  • 9 comments
  • 24 respects

Nano Light theremin

Project tutorial by jbrandstater

  • 1,952 views
  • 0 comments
  • 4 respects

SD Card Temperature Data Logger

Project tutorial by 3 developers

  • 11,954 views
  • 0 comments
  • 10 respects

Pulse Width Modulation Using a Potentiometer

by 3 developers

  • 14,432 views
  • 0 comments
  • 2 respects
Add projectSign up / Login