Ahmed Ebeed
Published © CC BY-NC-SA

How to Make Arduino Theremin -Control Arduino With Proximity

How to Make Arduino Theremin - Control Arduino With Proximity and Touch

IntermediateFull instructions provided30 minutes2,211
How to Make Arduino Theremin -Control Arduino With Proximity

Things used in this project

Story

Read more

Schematics

Arduino Theremin Circuit

Code

CapacitiveSensorSketchTone.ino

Arduino
No preview (download only).

Arduino Theremin Code

Arduino
#include <CapacitiveSensor.h>

/*
 * CapitiveSense Library Demo Sketch
 * Paul Badger 2008
 * Uses a high value resistor e.g. 10M between send pin and receive pin
 * Resistor effects sensitivity, experiment with values, 50K - 50M. Larger resistor values yield larger sensor values.
 * Receive pin is the sensor pin - try different amounts of foil/metal on this pin
 */


CapacitiveSensor   cs_4_2 = CapacitiveSensor(4,2);        // 10M resistor between pins 4 & 2, pin 2 is sensor pin, add a wire and or foil if desired


void setup()                    
{
//   cs_4_2.set_CS_AutocaL_Millis(0xFFFFFFFF);     // turn off autocalibrate on channel 1 - just as an example
   Serial.begin(9600);
}

void loop()                    
{
    long start = millis();
    long total1 =  cs_4_2.capacitiveSensor(30);


  // map the analog input range (in this case, 400 - 1000 from the photoresistor)
  // map the analog input range (in this case, 120 - 1000 from the photoresistor)
  // to the output pitch range (120 - 1500Hz)
  // change the minimum and maximum input numbers below depending on the range
  // your sensor's giving:

//  int thisPitch = map(total1, 400, 1000, 120, 1500);
  int thisPitch = map(total1, 400, 1500, 120, 1500);


 //   Serial.print(millis() - start);        // check on performance in milliseconds
    Serial.print("\t");                    // tab character for debug windown spacing

    Serial.print(total1);                  // print sensor output 1
    Serial.print("\t");
   
Serial.println(thisPitch);            // print sensor output 3

     delay(100);                             // arbitrary delay to limit data to serial port 


  
  // play the pitch:
  tone(8, thisPitch, 10);
  //delay(1);        // delay in between reads for stability







}

Credits

Ahmed Ebeed

Ahmed Ebeed

17 projects • 3 followers
Love to try new things and make stuff.
Thanks to Ahmed Ebeed.

Comments