官术网_书友最值得收藏!

The LDR sensor and the way it works

An LDR sensor is an analog input sensor that consists of a variable resistor whose resistance varies depending on the amount of light falling on its surface. When there is no light in the room, the resistance of the LDR sensor is HIGH (up to 1 M ohm) and in the presence of light, the resistance of the LDR sensor is LOW. The LDR sensor consists of two pins. These pins do not have positive and negative polarity. We can use any pin as a data or ground pin and because of this, the LDR sensor is sometimes referred to as a special type resistor. The image of the LDR sensor is shown in the following photo:

Since LDR is an analog sensor, we cannot connect it directly to the RPi as this does not contain an analog to digital converter (ADC) circuit. Because of this, RPi cannot read incoming analog data from an LDR sensor. So, instead of an LDR sensor, we will use an LDR digital sensor module, which will provide digital data to the RPi:

An LDR sensor module will read the incoming analog data from the LDR sensor and provide digital data in the form of HIGH or LOW as output. The LDR sensor module consists of 3 pins: D0 (data output), ground, and Vcc. D0 will provide digital data as output, which is further provided as input to RPi pins. The D0 pin will be HIGH in low light and will be LOW in the presence of light. The sensor module also consists of a potentiometer sensor, which can be used to vary the resistance of the LDR sensor.

Practical uses of the LDR sensor module is seen in street lamps, which automatically turn off during day time and turn on during night time. The smart light program that we are going to write is somewhat similar to this application, but instead of a street lamp, we are going to use an LED to keep things simple.

Now that we've gained an understanding of the basic way in which an LDR sensor works, next let's connect the LDR sensor module to Raspberry Pi.

主站蜘蛛池模板: 泾川县| 千阳县| 东台市| 淮安市| 澄江县| 岳西县| 子长县| 响水县| 中方县| 南京市| 班戈县| 漳州市| 沾益县| 筠连县| 镇宁| 建德市| 兴山县| 汉阴县| 昌吉市| 阿图什市| 龙海市| 梧州市| 蓬莱市| 和田市| 嘉峪关市| 如皋市| 南汇区| 锡林浩特市| 宣威市| 扬中市| 昭苏县| 通渭县| 五寨县| 尼木县| 永丰县| 新竹市| 富顺县| 裕民县| 南安市| 嘉黎县| 彩票|