9.Arduino learning notebook--Photocontrolled LED experiment

9.Arduino learning notebook--Photocontrolled LED experiment


             Juvtmall ( a company supply PCB PrototypingPCBA service and sell kinds of components, modules and so on) ( Catduino has the same function of Arduino)

The photosensitive resistor is also called the light pipe, and the commonly used materials are cadmium sulfide, as well as selenium, aluminum sulfide, lead sulphide and bismuth sulfide.These materials have a characteristic in which the resistance of the fabric is rapidly reduced at a given wavelength from the light. This is because the carrier of the light is involved in the conduction, in the role of external electric field drift movement, so that the resistance of the photosensitive resistor decreased rapidly. 

The working principle of photosensitive resistance is based on the internal photoelectric effect. At both ends of the semiconductor photosensitive material, the electrode wire is installed, which is encapsulated in the tube shell with a transparent window to form the photosensitive resistor. In order to increase the sensitivity, the two electrodes are often combed. In the light irradiation, the incoming light is strong, the resistance decreases, the incoming light is weak and the resistance increases.
The image below is a photosensitive resistor



The effect of this experiment is that led lights are off when the light is normal, and led lights when it is dark around.

Because the change of the photosensitive resistance affected by different illumination change is very big, so the parameters of this experiment is under 60W tricolor energy-saving lamps irradiation experiment (no sunlight). Also the brightness of the light photosensitive resistance's value will be much lower than the fluorescent lamp, which is maybe related with different wavelengths of light. Under the different environments, the parameters of the experiment also will be different . we adjust according to the principle.

Before the experiment, First measure the photosensitive resistance of the bright resistance and dark resistance value in the current environment.

The following figure is measured out of the LED bright resistance value, 9.1KΩ

The following figure is measured out of the LED dark resistance value, 32.4KΩ


The hardware connection diagram is as follows




According to the measured bright resistance 9.1KΩ, dark resistance 32.4KΩ.The selected divider resistance is 10KΩ. Because when there is a shelter, the resistance will become larger. Assuming a bright resistance of 10KΩ (for the photosensitive resistor, and is a little difference with the measured 9.1KΩ, so it is more convenient to calculate. ), the divider resistance is 10KΩ. The measured trigger voltage of the analog port 2 is 10KΩ divider resistor. In the 5V power supply, bright and dark conversion trigger voltage is 5 × 10 ÷ (10 +10) = 2.5V. When the darker the light, the greater the resistance of the photosensitive resistor will be, and the voltage across the voltage will be smaller. So the trigger condition is ≤ 2.5V.
(Undea the different lighting conditions, the trigger voltage is different. Please adjust according to the experimental environment.)

1. · int photocellPin = 2;/ / define variable photocellsh = 2 to read the port for voltage.
2. · int ledPin = 12;/ / define variable ledPin = 12 as led level output ports
3. · int val = 0;/ / define the start value of the val variable
4. ·
5. ·
6. · void setup () {
7. · pinMode (ledPin, the OUTPUT);/ / set the ledPin as output mode
8. ·}
9. ·
10. · void loop () {
11. · val = analogRead (photocellPin);/ / read the values from the sensor
12. · the if (val < = 512) {/ / 512 = 2.5 V, If you want sensor is sensitive for sometime, heighten the numerical value. Turn down the numerical value, the sensor will be slow.
13. · digitalWrite (ledPin, HIGH);/ / when val is less than 512 (2.5 V), the led is bright.
14. ·}
15. · the else {
16. · digitalWrite (ledPin, LOW);
17. ·}
18. }



The other blog

评论

此博客中的热门博文

21. Arduino learning notebook-- Experiment of controlling steering engine

20.Arduino learning notebook--Use Arduino Duemilanove to download the bootloader to other chips

19.Arduino learning notebook--Atmega8 makes the minimum arduino system