LDR Test
Dependencies: mbed
main.cpp@1:518bc17bc156, 2015-01-25 (annotated)
- Committer:
- Enenkel
- Date:
- Sun Jan 25 17:29:51 2015 +0000
- Revision:
- 1:518bc17bc156
- Parent:
- 0:eaf9c37db4a3
LDR-TEST
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
Enenkel | 0:eaf9c37db4a3 | 1 | /*********************************** |
Enenkel | 1:518bc17bc156 | 2 | name: BERTL_2014_TEST LDR Schaltet LEDs |
Enenkel | 1:518bc17bc156 | 3 | author: Gottfried Enenkel HTL BULME |
Enenkel | 0:eaf9c37db4a3 | 4 | email: ene@bulme.at |
Enenkel | 0:eaf9c37db4a3 | 5 | description: |
Enenkel | 0:eaf9c37db4a3 | 6 | je dünkler desto mehr LED leuchten |
Enenkel | 1:518bc17bc156 | 7 | ****************************************/ |
Enenkel | 1:518bc17bc156 | 8 | |
Enenkel | 0:eaf9c37db4a3 | 9 | // ********** Definitionen ***************** |
Enenkel | 0:eaf9c37db4a3 | 10 | #include "mbed.h" |
Enenkel | 0:eaf9c37db4a3 | 11 | |
Enenkel | 1:518bc17bc156 | 12 | DigitalOut ledD10(P1_8); // LED D10 |
Enenkel | 1:518bc17bc156 | 13 | DigitalOut ledD11(P1_9); |
Enenkel | 1:518bc17bc156 | 14 | DigitalOut ledD12(P1_10); |
Enenkel | 1:518bc17bc156 | 15 | DigitalOut ledD13(P1_11); |
Enenkel | 1:518bc17bc156 | 16 | AnalogIn LDR(P0_22); // LDR |
Enenkel | 0:eaf9c37db4a3 | 17 | |
Enenkel | 0:eaf9c37db4a3 | 18 | // ************* Hauptprogramm ****************** |
Enenkel | 0:eaf9c37db4a3 | 19 | int main() |
Enenkel | 0:eaf9c37db4a3 | 20 | { |
Enenkel | 0:eaf9c37db4a3 | 21 | while(1) |
Enenkel | 0:eaf9c37db4a3 | 22 | { |
Enenkel | 0:eaf9c37db4a3 | 23 | if(LDR <= 0.07) // Ab einer Lichtstärke von 0.15 oder kleiner |
Enenkel | 0:eaf9c37db4a3 | 24 | ledD10 = 1; // Ist die LED D10 EIN |
Enenkel | 0:eaf9c37db4a3 | 25 | else |
Enenkel | 0:eaf9c37db4a3 | 26 | ledD10 = 0; |
Enenkel | 0:eaf9c37db4a3 | 27 | |
Enenkel | 0:eaf9c37db4a3 | 28 | if (LDR <= 0.1) |
Enenkel | 0:eaf9c37db4a3 | 29 | ledD11=1; |
Enenkel | 0:eaf9c37db4a3 | 30 | else |
Enenkel | 0:eaf9c37db4a3 | 31 | ledD11=0; |
Enenkel | 0:eaf9c37db4a3 | 32 | |
Enenkel | 0:eaf9c37db4a3 | 33 | if (LDR <= 0.15) |
Enenkel | 0:eaf9c37db4a3 | 34 | ledD12=1; |
Enenkel | 0:eaf9c37db4a3 | 35 | else |
Enenkel | 0:eaf9c37db4a3 | 36 | ledD12=0; |
Enenkel | 0:eaf9c37db4a3 | 37 | |
Enenkel | 0:eaf9c37db4a3 | 38 | if(LDR <= 0.2) |
Enenkel | 0:eaf9c37db4a3 | 39 | ledD13=1; |
Enenkel | 0:eaf9c37db4a3 | 40 | else |
Enenkel | 0:eaf9c37db4a3 | 41 | ledD13=0; |
Enenkel | 0:eaf9c37db4a3 | 42 | |
Enenkel | 0:eaf9c37db4a3 | 43 | } |
Enenkel | 0:eaf9c37db4a3 | 44 | } |
Enenkel | 1:518bc17bc156 | 45 | // **************** ENDE ************************ |