Difference between revisions of "Arduino Theremin"

From OpenCircuits
Jump to navigation Jump to search
Line 20: Line 20:
  
 
== Measure Light Brightness Analog ==
 
== Measure Light Brightness Analog ==
 +
 +
The last program just told if the light was "on" or "off".  What we want to do is get an integer ( int ) that tell how bright the light is.  This is a conversion from the analog ( continuous ) value to a digital approximation.  To do this we use the Arduino's analog to digital converter ( adc ).  Open the project SerialBrightness1 and save it as SerialBrightnessAnalog.  Also open the sample project on analog to digital conversions Examples -> Analog -> AnalogInSerialOut.  This has pretty much all the code you need, but as an excercise use it as a guide to modifying your program.  Your program should output the brightness only when it changes.

Revision as of 07:06, 19 November 2009

This is a learning experience to use an Arduino to make a version of the Theremin. The Theremin is a musical instrument that is played just by putting your hands near the instrument:

The Theremin normally uses radio waves to detect the position of the hands, we will use light falling on a photo resistor instead, and for now just to pitch and skip loudness.

Approach

It is often good to do a project by breaking it down into steps and make sure that each step works before making the project more complicated. We will do this in two way. We will build the project up a step at a time, and we will when possible "steal" code from other projects and adapt it to ours.

Debugging/Logging Project

It is nice to have a seral port to control a project and have the project report back to you. We have done this in a couple of projects. Lets steal the code from SerialSound2 and save it into a new project called SerialLog1. Modify the code so all it does is recieves the incomming character, add one to it and send it back. Let Mr. H check the code when you think this part is done.

Measure Light Brightness

To start this stage in the project open SerialLog1 and save it as SerialBrightness1. Now in another project ( LDR ) we had a light dependent resistor and blinked some LED's depending on the brightness. Lets steal some of that code and add it to the current one SerialLog1. Modify the code so that when the light goes from on to off the Arduino sends "light off" and when it goes from off to on it sends "light on", and finally when the light does not change the Arduino sends nothing.

Let Mr. H check the code when you think this part is done.

Measure Light Brightness Analog

The last program just told if the light was "on" or "off". What we want to do is get an integer ( int ) that tell how bright the light is. This is a conversion from the analog ( continuous ) value to a digital approximation. To do this we use the Arduino's analog to digital converter ( adc ). Open the project SerialBrightness1 and save it as SerialBrightnessAnalog. Also open the sample project on analog to digital conversions Examples -> Analog -> AnalogInSerialOut. This has pretty much all the code you need, but as an excercise use it as a guide to modifying your program. Your program should output the brightness only when it changes.