eeng:topics:photocells:start
Differences
This shows you the differences between two versions of the page.
| Both sides previous revisionPrevious revisionNext revision | Previous revision | ||
| eeng:topics:photocells:start [2022/10/17 11:32] – [Photocells / Light Dependent Resistors (LDR)] rolf | eeng:topics:photocells:start [2023/11/22 01:07] (current) – [About LDR] rolf | ||
|---|---|---|---|
| Line 1: | Line 1: | ||
| ====== Photocells / Light Dependent Resistors (LDR) ====== | ====== Photocells / Light Dependent Resistors (LDR) ====== | ||
| + | ===== Lecture Slides ===== | ||
| - | | {{https:// | + | * {{ : |
| - | | Fig.: A cadmium sulfide (CdS) photocell. (Source: [[https:// | + | |
| + | ===== About LDR ===== | ||
| + | |||
| + | | {{https:// | ||
| + | | Fig.: A cadmium sulfide (CdS) photocell. | ||
| "The cadmium sulfide (CdS) or light dependent resistor (LDR) whose resistance is inversly dependent | "The cadmium sulfide (CdS) or light dependent resistor (LDR) whose resistance is inversly dependent | ||
| Line 13: | Line 18: | ||
| - {{https:// | - {{https:// | ||
| - | === High Variability === | + | |
| + | |||
| + | ==== Large Variance among specimen of the same product series ==== | ||
| + | |||
| + | The GL5528 datasheet from Sparkfun illustrates the broad performance variety between LDR of the same type: | ||
| + | |||
| + | * :!: https:// | ||
| + | |||
| + | ==== LUX ==== | ||
| + | |||
| + | The light " | ||
| + | |||
| + | |||
| + | "The lux (symbol: lx) is the **unit of illuminance, | ||
| + | |||
| + | |||
| + | |||
| + | ==== High Performance | ||
| Do not trust the resistance-vs-lux curves too much. Adafruit states on its tutorial on Photocells for Arduino: | Do not trust the resistance-vs-lux curves too much. Adafruit states on its tutorial on Photocells for Arduino: | ||
| Line 20: | Line 42: | ||
| | {{https:// | | {{https:// | ||
| - | | Fig.: Typical performance variation of a photocells (log-log-plot). \\ (Source: [[http:// | + | | Fig.: Typical performance variation of photocells |
| The [[http:// | The [[http:// | ||
| - | === LUX === | ||
| - | The light " | ||
| + | ===== LDR Voltage Divider Experiment with Arduino ===== | ||
| + | |||
| + | | {{ : | ||
| + | | Fig.: Schematic. | | ||
| + | |||
| + | | {{ : | ||
| + | | Fig.: Breadboard view. | | ||
| + | ===== Arduino Code: ADC to Serial ===== | ||
| + | |||
| + | <code c++ LDR_V001.ino> | ||
| + | |||
| + | /* | ||
| + | * Voltage divider with LDR | ||
| + | | ||
| + | * Circuit: | ||
| + | * 5V (Vcc) - LDR - R1 - GND | ||
| + | * The node between LDR and R1 (V1, voltage drop across R1) is connected to analog input A0 | ||
| + | * R1 arbitrary, e.g. 10kOhms | ||
| + | | ||
| + | * The voltage V1 is converted to a digital number (dn) by means of an analog-to-digital converter (ADC). | ||
| + | * The range of dn: 0 <= dn <= 1023 (10 bit resolution) | ||
| + | | ||
| + | * Conversion: | ||
| + | * V1 = 0V -> dn = 0 | ||
| + | * V1 = 5V -> dn = 1023 | ||
| + | | ||
| + | * Reconstruction of voltage from digital number: | ||
| + | * V = dn / 1023 * 5V | ||
| + | | ||
| + | */ | ||
| - | "The lux (symbol: lx) is the unit of illuminance, | + | int AIN = A0; // Analog input pin number |
| + | void setup() { | ||
| + | // put your setup code here, to run once: | ||
| + | Serial.begin(115200); | ||
| + | Serial.println(" | ||
| + | } | ||
| + | void loop() { | ||
| + | // put your main code here, to run repeatedly: | ||
| + | | ||
| + | int dn = analogRead(AIN); | ||
| + | float V = (float)dn / 1024 * 5.0; // convert dn to float first, then divide by 1024 | ||
| + | int mV = V*1000; // millivolts, converted from float | ||
| + | | ||
| + | Serial.print(dn); | ||
| + | Serial.print(" | ||
| + | Serial.print(V); | ||
| + | Serial.print(" | ||
| + | Serial.println(mV); | ||
| + | | ||
| + | delay(100); // pause in ms, 100 ms means 10 meas / sec. | ||
| + | } | ||
| + | </ | ||
eeng/topics/photocells/start.1666006339.txt.gz · Last modified: 2022/10/17 11:32 by rolf
