Difference between revisions of "Arduino Theremin"
(→Measure Light Brightness: clarify (I hope)) |
Russ hensel (talk | contribs) |
||
Line 21: | Line 21: | ||
Circuit: | Circuit: | ||
− | + | ||
+ | [[File:VdivideLDR.png]] | ||
+ | |||
+ | Where | ||
+ | |||
+ | Input = 5v from power supply Vcc | ||
+ | Output = signal to connect to Arduino Input Pin | ||
+ | |||
+ | Note that the LDR is is on the "high side" wo in the dark where its reisistance is high the ouput voltage will be low. | ||
+ | |||
Let Mr. H check the code when you think this part is done. | Let Mr. H check the code when you think this part is done. |
Revision as of 16:33, 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.
Contents
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.
A note on the light dependent circuit. You need to use a resistor in series with the light dependent resistor, this combination lets a variable current flow through the circuit. The voltage across the resistor will vary with the light brightness ( so will the voltage across the LDR, the two will total to 5 volts. ) What size resistor should you use? Put the LDR in medium brightness and mesure its resistance with a ohm meter. Use that value resistor then in medium light you will get 2.5 volts into the Arduino.
Circuit:
Where
Input = 5v from power supply Vcc Output = signal to connect to Arduino Input Pin
Note that the LDR is is on the "high side" wo in the dark where its reisistance is high the ouput voltage will be low.
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.