This book will help you to gain more knowledge about Arduino
Beginning Arduino
Circuit diagram Arduino Light Sensor :
First, make sure your Arduino is powered off by unplugging it from the USB cable. Then, connect up your parts so you have the circuit. Check all of your connections before reconnecting the power to the Arduino.
The LDR can be inserted any way around; it does not have polarity. I found a 10kΩ resistor worked well with my LDR. You may need to try different resistor settings until you find one suitable for the LDR you have. A value between 1kΩ and 10kΩ should do the trick. Having a selection of different common resistor values in your component box will always come in handy.
[caption id="attachment_448" align="alignnone" width="300"] Light Sensor[/caption]
Code Arduino Light Sensor :
int piezoPin = 8; // Piezo on Pin 8 int ldrPin = 0; // LDR on Analog Pin 0 int ldrValue = 0; // Value read from the LDR void setup() { // nothing to do here } void loop() { ldrValue = analogRead(ldrPin); // read the value from the LDR tone(piezoPin,1000); // play a 1000Hz tone from the piezo delay(25); // wait a bit noTone(piezoPin); // stop the tone delay(ldrValue); // wait the amount of milliseconds in ldrValue }When you upload this code to the Arduino, the Arduino will start to make short beeps. The gap between the beeps will be long if the LDR is in the shade and will be short when bright light is shone on it. This will give a Geiger counter-type effect, but with our detector detecting photon particles instead of ionizing radiation. You may find it more practical to solder a set of long wires to the LDR to allow you to keep your breadboard and Arduino on the table but move your LDR around to point it in dark and light areas. ALL ARDUINO TUTORIAL
Discussions
Become a Hackaday.io Member
Create an account to leave a comment. Already have an account? Log In.