Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
Dependencies: mbed
Fork of _B14Test7 by
main.cpp@0:eaf9c37db4a3, 2014-11-14 (annotated)
- Committer:
- Enenkel
- Date:
- Fri Nov 14 14:01:48 2014 +0000
- Revision:
- 0:eaf9c37db4a3
- Child:
- 1:518bc17bc156
LDR Test
Who changed what in which revision?
| User | Revision | Line number | New contents of line |
|---|---|---|---|
| Enenkel | 0:eaf9c37db4a3 | 1 | /*********************************** |
| Enenkel | 0:eaf9c37db4a3 | 2 | name: BERTL_2014_TEST i2C Schalter und LEDs |
| Enenkel | 0:eaf9c37db4a3 | 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 | 0:eaf9c37db4a3 | 7 | ****************************************/ |
| Enenkel | 0:eaf9c37db4a3 | 8 | // ********** Definitionen ***************** |
| Enenkel | 0:eaf9c37db4a3 | 9 | #include "mbed.h" |
| Enenkel | 0:eaf9c37db4a3 | 10 | |
| Enenkel | 0:eaf9c37db4a3 | 11 | DigitalOut ledD10(LED1); // LED D10 |
| Enenkel | 0:eaf9c37db4a3 | 12 | DigitalOut ledD11(LED2); |
| Enenkel | 0:eaf9c37db4a3 | 13 | DigitalOut ledD12(LED3); |
| Enenkel | 0:eaf9c37db4a3 | 14 | DigitalOut ledD13(LED4); |
| Enenkel | 0:eaf9c37db4a3 | 15 | AnalogIn LDR(p20); // LDR |
| Enenkel | 0:eaf9c37db4a3 | 16 | |
| Enenkel | 0:eaf9c37db4a3 | 17 | // ************* Hauptprogramm ****************** |
| Enenkel | 0:eaf9c37db4a3 | 18 | int main() |
| Enenkel | 0:eaf9c37db4a3 | 19 | { |
| Enenkel | 0:eaf9c37db4a3 | 20 | while(1) |
| Enenkel | 0:eaf9c37db4a3 | 21 | { |
| Enenkel | 0:eaf9c37db4a3 | 22 | if(LDR <= 0.07) // Ab einer Lichtstärke von 0.15 oder kleiner |
| Enenkel | 0:eaf9c37db4a3 | 23 | ledD10 = 1; // Ist die LED D10 EIN |
| Enenkel | 0:eaf9c37db4a3 | 24 | else |
| Enenkel | 0:eaf9c37db4a3 | 25 | ledD10 = 0; |
| Enenkel | 0:eaf9c37db4a3 | 26 | |
| Enenkel | 0:eaf9c37db4a3 | 27 | if (LDR <= 0.1) |
| Enenkel | 0:eaf9c37db4a3 | 28 | ledD11=1; |
| Enenkel | 0:eaf9c37db4a3 | 29 | else |
| Enenkel | 0:eaf9c37db4a3 | 30 | ledD11=0; |
| Enenkel | 0:eaf9c37db4a3 | 31 | |
| Enenkel | 0:eaf9c37db4a3 | 32 | if (LDR <= 0.15) |
| Enenkel | 0:eaf9c37db4a3 | 33 | ledD12=1; |
| Enenkel | 0:eaf9c37db4a3 | 34 | else |
| Enenkel | 0:eaf9c37db4a3 | 35 | ledD12=0; |
| Enenkel | 0:eaf9c37db4a3 | 36 | |
| Enenkel | 0:eaf9c37db4a3 | 37 | if(LDR <= 0.2) |
| Enenkel | 0:eaf9c37db4a3 | 38 | ledD13=1; |
| Enenkel | 0:eaf9c37db4a3 | 39 | else |
| Enenkel | 0:eaf9c37db4a3 | 40 | ledD13=0; |
| Enenkel | 0:eaf9c37db4a3 | 41 | |
| Enenkel | 0:eaf9c37db4a3 | 42 | } |
| Enenkel | 0:eaf9c37db4a3 | 43 | } |
| Enenkel | 0:eaf9c37db4a3 | 44 | // **************** ENDE ************************ |
| Enenkel | 0:eaf9c37db4a3 | 45 | |
| Enenkel | 0:eaf9c37db4a3 | 46 | |
| Enenkel | 0:eaf9c37db4a3 | 47 | |
| Enenkel | 0:eaf9c37db4a3 | 48 | /* |
| Enenkel | 0:eaf9c37db4a3 | 49 | #include "mbed.h" |
| Enenkel | 0:eaf9c37db4a3 | 50 | // ************ DEKLARATIONEN ************** |
| Enenkel | 0:eaf9c37db4a3 | 51 | DigitalOut LED_D10(P1_8); // Alle Blauen LED gehen auf einen Anschluß |
| Enenkel | 0:eaf9c37db4a3 | 52 | DigitalOut LED_D13(P1_10); // P1..Port1 _28 Anschluß 28 |
| Enenkel | 0:eaf9c37db4a3 | 53 | |
| Enenkel | 0:eaf9c37db4a3 | 54 | DigitalIn LDR(P0_22); // LRD Sensor |
| Enenkel | 0:eaf9c37db4a3 | 55 | DigitalIn SensorR(P1_13); // Sensor Rechts |
| Enenkel | 0:eaf9c37db4a3 | 56 | |
| Enenkel | 0:eaf9c37db4a3 | 57 | // ************ HAUPT PROGRAMM ************** |
| Enenkel | 0:eaf9c37db4a3 | 58 | int main() { |
| Enenkel | 0:eaf9c37db4a3 | 59 | |
| Enenkel | 0:eaf9c37db4a3 | 60 | while(1) { |
| Enenkel | 0:eaf9c37db4a3 | 61 | LED_D10 = SensorL; // |
| Enenkel | 0:eaf9c37db4a3 | 62 | LED_D13 = SensorR; |
| Enenkel | 0:eaf9c37db4a3 | 63 | } |
| Enenkel | 0:eaf9c37db4a3 | 64 | } |
| Enenkel | 0:eaf9c37db4a3 | 65 | |
| Enenkel | 0:eaf9c37db4a3 | 66 | // ***************** ENDE ******************** |
| Enenkel | 0:eaf9c37db4a3 | 67 | |
| Enenkel | 0:eaf9c37db4a3 | 68 | */ |
| Enenkel | 0:eaf9c37db4a3 | 69 |
