![](/media/cache/group/ep.webp.50x50_q85.jpg)
Licht Sensor
Dependencies: mbed
Ein Fotowiderstand (englisch Light Dependent Resistor, LDR) ist ein Lichtabhängiger Widerstand aus einer amorphen Halbleiter-Schicht. Je höher der Lichteinfall, desto kleiner wird aufgrund des inneren fotoelektrischen Effekts sein elektrischer Widerstand.
Der Fotowiderstand kann nicht direkt mit einem analogen Pin verbunden werden, da dieser nur Spannungen und keine Widerstände messen kann. Die Lösung ist die die Spannungsteiler Schaltung. Die Kombination Fotowiderstand und Spannungsteiler ergibt einen Licht Sensor.
Anwendungen
- Dämmerungsschalter
main.cpp@2:79735a854c53, 2015-08-15 (annotated)
- Committer:
- marcel1691
- Date:
- Sat Aug 15 20:01:13 2015 +0200
- Revision:
- 2:79735a854c53
- Parent:
- 1:d97ed63aad9c
Erweitert um Eclipse/gcc4mbed Konfiguration
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
stefan1691 | 1:d97ed63aad9c | 1 | /** Liest die analoge Spannung an einem Pin. |
stefan1691 | 1:d97ed63aad9c | 2 | Hier der Lichtsensor auf A1. |
marcel1691 | 0:a8b5bbd75472 | 3 | */ |
marcel1691 | 0:a8b5bbd75472 | 4 | #include "mbed.h" |
marcel1691 | 0:a8b5bbd75472 | 5 | |
stefan1691 | 1:d97ed63aad9c | 6 | AnalogIn licht( A1 ); |
stefan1691 | 1:d97ed63aad9c | 7 | DigitalOut led1 ( D10 ); |
marcel1691 | 0:a8b5bbd75472 | 8 | |
marcel1691 | 0:a8b5bbd75472 | 9 | int main() |
marcel1691 | 0:a8b5bbd75472 | 10 | { |
stefan1691 | 1:d97ed63aad9c | 11 | while ( 1 ) |
marcel1691 | 0:a8b5bbd75472 | 12 | { |
stefan1691 | 1:d97ed63aad9c | 13 | if ( licht.read() < 0.8f ) // in Prozent |
stefan1691 | 1:d97ed63aad9c | 14 | led1 = 1; |
stefan1691 | 1:d97ed63aad9c | 15 | else |
stefan1691 | 1:d97ed63aad9c | 16 | led1 = 0; |
marcel1691 | 2:79735a854c53 | 17 | wait ( 1.0 ); |
marcel1691 | 2:79735a854c53 | 18 | } |
marcel1691 | 2:79735a854c53 | 19 | } |