I checked in the LDR posts but couldn't find anything relating to my particular project.
I'm an Arduino beginner and would appreciate a nudge in the right direction, regarding my questions below.
In a project with blind students, I want to build an acoustic light meter. That's to say the frequency of the piezo buzzer should be proportional to the amount of light (the lighter, the higher the frequency).
This is an aide many blind people use to check if someone has left the light on, whether the sun shines or where the windows are in an unfamiliar room.
I don't know if I should use an LDR or a photo diode. I have read that LDRs react sluggish and are sensitive to temperature changes. So a diode seems more suitable.
I don't know which properties the resistor or diode should have in terms of sensitivity.
I'm hoping that someone can point me towards a code example that might be adapted for my purpose.
I should add that I am blind myself, so for instance can't use circuit diagrams. However, I can easily feel my way around the board and connect pins. For coding I use the web editor since I don't know of an IDE accessible to blind people.
I would be grateful of any input.
No use an LDR. They are only sluggish in the respect of fast signals, they are ideal for your project.
The resistor should have the same value as the mid light level of the LDR, it is not too critical to make it exactly the same but as close as you can get.
Use the tone library to generate the sounds.
The circuit is simple. LDR to the 5V and analogue input. Resistor from the analogue input to ground.
Proportional may not give the best result...
Light intensity can change over several log units. That is why it is often measured on a log scale.
Tone increases by an octave per factor 2. A 5 Hz difference gives a really different tone at 110 Hz, but the difference will be difficult to hear at 5000 Hz.
So you might want to try non linear functions.
Maybe you are lucky since they are both non linear...
Among the examples for the web editor, I found: Arduino Starter Kit > Project 6 > Light Theremin
I believe this does what I want to do. However, I can't find any written info on how it is wired.
I've got the required parts, an LDR, a 10k Ohm resistor and a piezo buzzer, but don't know how to connect them.
If the LDR goes from V5 to A0 (as per the code), then from where does the resistor go to Ground? And if the buzzer gets its input from pin 8 (again as per the code), where does its second leg go? Shouldn't it also be grounded?
I'd be glad of any advice.
The LDR and resistor go in series with one end of the pair going to +5V and the other end to ground. The junction goes to the analog input.
It doesn't matter if the LDR or fixed resistor goes to 5V. One way, more light will give more voltage and the other way more light will give less voltage. The logic can also be reversed in software.
As always, work on the input & output separately. The Analog Read Serial Example sends the analog reading to the Serial Monitor, and hopefully your screen reader can read it. (The example uses a potentiometer but the same code will work with any analog input.)
You can use the map() function to map a range of analog readings to a range of audio frequencies.
And a note about piezo "buzzers". Technically a "buzzer" is a device that has a tone-generator circuit built-into it. You power it with DC voltage and it makes a tone and you can't change the tone/frequency.
What you really want is a piezo transducer or piezo speaker that reproduces the frequency you feed into it.
They are similar and some sellers mis-name them so it can be confusing. If you have a transducer or speaker it won't make a sound when you apply 5VDC, except it might make a tiny click when you apply or disconnect power.
Also piezo transducers are basically "tweeters" They are not good at low frequencies. (Musical greeting cards use piezo transducers.)
The most common is solderless bread board. Especially for temporary or experimental circuits.
However I very rarely use that myself, because most of the time I have a clear idea of what I am making. What I do is either make a shield for a Uno and solder the parts on top of that. http://www.thebox.myzen.co.uk/Hardware/MIDI_Shield.html
You can also buy prototype shield boards to save you the hassle of making one.
Or if I am using a Nano or similar shaped board I fit the processor with header pins, then using strip socket solder that to strip board like Vero board.
Thanks for your support guys. I've now got a bread board and have successfully built my first circuit. The code does what I want it to do. This is due to the information I got from you.
For anyone wanting to do a similar project I'll ad some advice of my own.
I found that piezo speakers are not ideal for this purpose. They produce overtones which can make an actual low tone seam high. When trying to determine whether it's light or dark by having a hight tone represent light and a low tone represent darkness, as well as a range of tones representing levels of brightness in between, overtones can be misleading.
I found that magnet speakers, which you can get in quite small sizes, are much better suited.