Testet BERTL17 zuerst die LED's dann nach Tasterdruck jeweils die dazugehörigen LED
Dependencies: mbed
main.cpp@4:a33d2e24765a, 2016-04-21 (annotated)
- Committer:
- Enenkel
- Date:
- Thu Apr 21 12:14:03 2016 +0000
- Revision:
- 4:a33d2e24765a
- Parent:
- 3:bff0f9cba269
- Child:
- 5:8d00369f47e9
BERTL16 Test1
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
Enenkel | 0:a8a0195ed7dc | 1 | /*********************************** |
Enenkel | 4:a33d2e24765a | 2 | name: BERTL16_Test1 8.1.2016 |
Enenkel | 1:628da1b465a4 | 3 | author: Enenkel |
Enenkel | 4:a33d2e24765a | 4 | description: TEST1 testet die 3,3V und 3,7V |
Enenkel | 4:a33d2e24765a | 5 | -> Die 12 LEDs blinken 2 mal der Reihe nach auf |
Enenkel | 4:a33d2e24765a | 6 | -> Dann blinken alle LED 2x |
Enenkel | 4:a33d2e24765a | 7 | -> Danach blinken die 2 bleuen LED mehrfach |
Enenkel | 4:a33d2e24765a | 8 | -> Dann leuchtet bei jedem Tastendruck eine oder mehrere LED auf |
Enenkel | 4:a33d2e24765a | 9 | -> UND beim Abdunkeln des LDR leuchten die LED D10 - D13 auf |
Enenkel | 3:bff0f9cba269 | 10 | |
Enenkel | 0:a8a0195ed7dc | 11 | ***********************************/ |
Enenkel | 0:a8a0195ed7dc | 12 | #include "mbed.h" |
Enenkel | 4:a33d2e24765a | 13 | |
Enenkel | 4:a33d2e24765a | 14 | // Definition der LEDS als AUSGANGE |
Enenkel | 4:a33d2e24765a | 15 | DigitalOut LedD1 (P1_10); |
Enenkel | 4:a33d2e24765a | 16 | DigitalOut LedD2 (P1_11); |
Enenkel | 4:a33d2e24765a | 17 | DigitalOut LedD4 (P1_12); |
Enenkel | 4:a33d2e24765a | 18 | DigitalOut LedD5 (P1_13); |
Enenkel | 4:a33d2e24765a | 19 | DigitalOut LedD6 (P1_14); |
Enenkel | 4:a33d2e24765a | 20 | DigitalOut LedD7 (P1_15); |
Enenkel | 4:a33d2e24765a | 21 | DigitalOut LedD8 (P1_16); |
Enenkel | 4:a33d2e24765a | 22 | DigitalOut LedD9 (P1_17); |
Enenkel | 4:a33d2e24765a | 23 | DigitalOut LedD10 (P1_18); |
Enenkel | 4:a33d2e24765a | 24 | DigitalOut LedD11 (P1_19); |
Enenkel | 4:a33d2e24765a | 25 | DigitalOut LedD12 (P1_20); |
Enenkel | 4:a33d2e24765a | 26 | DigitalOut LedD13 (P1_21); |
Enenkel | 2:040855fee6fa | 27 | |
Enenkel | 4:a33d2e24765a | 28 | //Definition der Schalter als Eingange |
Enenkel | 4:a33d2e24765a | 29 | DigitalIn TA1 (P1_23); |
Enenkel | 4:a33d2e24765a | 30 | DigitalIn TA2 (P1_24); |
Enenkel | 4:a33d2e24765a | 31 | DigitalIn TA3 (P1_25); |
Enenkel | 4:a33d2e24765a | 32 | DigitalIn TA4 (P1_26); |
Enenkel | 4:a33d2e24765a | 33 | DigitalIn TA5 (P1_27); |
Enenkel | 4:a33d2e24765a | 34 | DigitalIn TA6 (P1_28); |
Enenkel | 4:a33d2e24765a | 35 | DigitalIn TA7 (P1_30); |
Enenkel | 4:a33d2e24765a | 36 | DigitalIn TA8 (P1_31); |
Enenkel | 1:628da1b465a4 | 37 | |
Enenkel | 4:a33d2e24765a | 38 | void lamptest(); |
Enenkel | 4:a33d2e24765a | 39 | void tastertest(); |
Enenkel | 4:a33d2e24765a | 40 | void ldrtest(); // testet die LDR |
Enenkel | 4:a33d2e24765a | 41 | AnalogIn LDR (P0_14); // Adresse der LDR |
Enenkel | 4:a33d2e24765a | 42 | void blueledtest(); // Tested die blauen LED |
Enenkel | 4:a33d2e24765a | 43 | DigitalOut BlueLed (P1_5); |
Enenkel | 4:a33d2e24765a | 44 | void RGBtest(); // Derzeit nicht dabei |
Enenkel | 4:a33d2e24765a | 45 | DigitalOut RGB (P1_22); // Adresse RGB LED |
Enenkel | 4:a33d2e24765a | 46 | |
Enenkel | 4:a33d2e24765a | 47 | |
Enenkel | 4:a33d2e24765a | 48 | // ************* Hauptprogramm ************************ |
Enenkel | 1:628da1b465a4 | 49 | int a; |
Enenkel | 4:a33d2e24765a | 50 | int b; |
Enenkel | 4:a33d2e24765a | 51 | int main() { |
Enenkel | 4:a33d2e24765a | 52 | lamptest(); // Alle LED einmal blinken |
Enenkel | 4:a33d2e24765a | 53 | blueledtest(); // Tested die blauen LED |
Enenkel | 4:a33d2e24765a | 54 | tastertest(); // läuft ewig weiter ! ! |
Enenkel | 4:a33d2e24765a | 55 | |
Enenkel | 4:a33d2e24765a | 56 | |
Enenkel | 4:a33d2e24765a | 57 | |
Enenkel | 4:a33d2e24765a | 58 | |
Enenkel | 4:a33d2e24765a | 59 | |
Enenkel | 4:a33d2e24765a | 60 | } |
Enenkel | 1:628da1b465a4 | 61 | |
Enenkel | 4:a33d2e24765a | 62 | // UNTEPROGRAMME ****************************************************** |
Enenkel | 4:a33d2e24765a | 63 | void lamptest() { //***************************************************** |
Enenkel | 4:a33d2e24765a | 64 | a=0; |
Enenkel | 4:a33d2e24765a | 65 | while (a<2) { // 2 Mal durch die Schleife laufen |
Enenkel | 4:a33d2e24765a | 66 | // Alle LED einmal blinken (2 Mal durchlaufen |
Enenkel | 4:a33d2e24765a | 67 | LedD1=1; // LED D1 ON |
Enenkel | 4:a33d2e24765a | 68 | wait (0.5); // 0.5 sec warten |
Enenkel | 4:a33d2e24765a | 69 | LedD1=0; // LED D1 AUS |
Enenkel | 4:a33d2e24765a | 70 | LedD2=1; // LED D2 EIN |
Enenkel | 4:a33d2e24765a | 71 | wait (0.5); |
Enenkel | 4:a33d2e24765a | 72 | LedD2=0; |
Enenkel | 4:a33d2e24765a | 73 | LedD4=1; |
Enenkel | 4:a33d2e24765a | 74 | wait (0.5); |
Enenkel | 4:a33d2e24765a | 75 | LedD4=0; |
Enenkel | 4:a33d2e24765a | 76 | LedD5=1; |
Enenkel | 4:a33d2e24765a | 77 | wait (0.5); |
Enenkel | 4:a33d2e24765a | 78 | LedD5=0; |
Enenkel | 4:a33d2e24765a | 79 | LedD6=1; |
Enenkel | 4:a33d2e24765a | 80 | wait (0.5); |
Enenkel | 4:a33d2e24765a | 81 | LedD6=0; |
Enenkel | 4:a33d2e24765a | 82 | LedD7=1; |
Enenkel | 4:a33d2e24765a | 83 | wait (0.5); |
Enenkel | 4:a33d2e24765a | 84 | LedD7=0; |
Enenkel | 4:a33d2e24765a | 85 | LedD8=1; |
Enenkel | 4:a33d2e24765a | 86 | wait (0.5); |
Enenkel | 4:a33d2e24765a | 87 | LedD8=0; |
Enenkel | 4:a33d2e24765a | 88 | LedD9=1; |
Enenkel | 4:a33d2e24765a | 89 | wait (0.5); |
Enenkel | 4:a33d2e24765a | 90 | LedD9=0; |
Enenkel | 4:a33d2e24765a | 91 | LedD10=1; |
Enenkel | 4:a33d2e24765a | 92 | wait (0.5); |
Enenkel | 4:a33d2e24765a | 93 | LedD10=0; |
Enenkel | 4:a33d2e24765a | 94 | LedD11=1; |
Enenkel | 4:a33d2e24765a | 95 | wait (0.5); |
Enenkel | 4:a33d2e24765a | 96 | LedD11=0; |
Enenkel | 4:a33d2e24765a | 97 | LedD12=1; |
Enenkel | 4:a33d2e24765a | 98 | wait (0.5); |
Enenkel | 4:a33d2e24765a | 99 | LedD12=0; |
Enenkel | 4:a33d2e24765a | 100 | LedD13=1; |
Enenkel | 4:a33d2e24765a | 101 | wait (0.5); |
Enenkel | 4:a33d2e24765a | 102 | LedD13=0; |
Enenkel | 4:a33d2e24765a | 103 | wait (0.5); |
Enenkel | 4:a33d2e24765a | 104 | |
Enenkel | 4:a33d2e24765a | 105 | b=0; |
Enenkel | 4:a33d2e24765a | 106 | while (b<2) // Alle LED blinken 2 Mal |
Enenkel | 4:a33d2e24765a | 107 | { |
Enenkel | 4:a33d2e24765a | 108 | LedD1=LedD2=LedD4=LedD5=LedD6=LedD7=LedD8=LedD9=LedD10=LedD11=LedD12=LedD13=1; |
Enenkel | 4:a33d2e24765a | 109 | wait (0.5); |
Enenkel | 4:a33d2e24765a | 110 | LedD1=LedD2=LedD4=LedD5=LedD6=LedD7=LedD8=LedD9=LedD10=LedD11=LedD12=LedD13=0; |
Enenkel | 4:a33d2e24765a | 111 | wait (0.5); |
Enenkel | 4:a33d2e24765a | 112 | b=b++; |
Enenkel | 4:a33d2e24765a | 113 | } |
Enenkel | 4:a33d2e24765a | 114 | a=a++; // a = a+1 -> in C besser a++ |
Enenkel | 4:a33d2e24765a | 115 | } |
Enenkel | 4:a33d2e24765a | 116 | } |
Enenkel | 2:040855fee6fa | 117 | |
Enenkel | 4:a33d2e24765a | 118 | // *************************************************************************** |
Enenkel | 4:a33d2e24765a | 119 | void tastertest() { //Taster Test Bei Drücken einer Taste leuchtet die LED ! |
Enenkel | 4:a33d2e24765a | 120 | while(1) // läuft ewig weiter |
Enenkel | 4:a33d2e24765a | 121 | { |
Enenkel | 4:a33d2e24765a | 122 | if (TA1 == 1) { |
Enenkel | 4:a33d2e24765a | 123 | LedD10=LedD11=LedD12=LedD13=1; |
Enenkel | 4:a33d2e24765a | 124 | } |
Enenkel | 4:a33d2e24765a | 125 | else { |
Enenkel | 4:a33d2e24765a | 126 | LedD10=LedD11=LedD12=LedD13=0; |
Enenkel | 4:a33d2e24765a | 127 | } |
Enenkel | 4:a33d2e24765a | 128 | if (TA2 == 1) { |
Enenkel | 4:a33d2e24765a | 129 | LedD4=1; |
Enenkel | 4:a33d2e24765a | 130 | } |
Enenkel | 4:a33d2e24765a | 131 | else { |
Enenkel | 4:a33d2e24765a | 132 | LedD4=0; |
Enenkel | 4:a33d2e24765a | 133 | } |
Enenkel | 4:a33d2e24765a | 134 | if (TA3 == 1) { |
Enenkel | 4:a33d2e24765a | 135 | LedD1=1; |
Enenkel | 4:a33d2e24765a | 136 | } |
Enenkel | 4:a33d2e24765a | 137 | else { |
Enenkel | 4:a33d2e24765a | 138 | LedD1=0; |
Enenkel | 4:a33d2e24765a | 139 | } |
Enenkel | 4:a33d2e24765a | 140 | if (TA4 == 1) { |
Enenkel | 4:a33d2e24765a | 141 | LedD6=LedD8=1; |
Enenkel | 4:a33d2e24765a | 142 | } |
Enenkel | 4:a33d2e24765a | 143 | else { |
Enenkel | 4:a33d2e24765a | 144 | LedD6=LedD8=0; |
Enenkel | 4:a33d2e24765a | 145 | } |
Enenkel | 4:a33d2e24765a | 146 | if (TA5 == 1) { |
Enenkel | 4:a33d2e24765a | 147 | LedD7=1; |
Enenkel | 4:a33d2e24765a | 148 | } |
Enenkel | 4:a33d2e24765a | 149 | else { |
Enenkel | 4:a33d2e24765a | 150 | LedD7=0; |
Enenkel | 4:a33d2e24765a | 151 | } |
Enenkel | 4:a33d2e24765a | 152 | if (TA6 == 1) { |
Enenkel | 4:a33d2e24765a | 153 | LedD9=1; |
Enenkel | 4:a33d2e24765a | 154 | } |
Enenkel | 4:a33d2e24765a | 155 | else { |
Enenkel | 4:a33d2e24765a | 156 | LedD9=0; |
Enenkel | 4:a33d2e24765a | 157 | } |
Enenkel | 4:a33d2e24765a | 158 | if (TA7 == 1) { |
Enenkel | 4:a33d2e24765a | 159 | LedD5=1; |
Enenkel | 4:a33d2e24765a | 160 | } |
Enenkel | 4:a33d2e24765a | 161 | else { |
Enenkel | 4:a33d2e24765a | 162 | LedD5=0; |
Enenkel | 4:a33d2e24765a | 163 | } |
Enenkel | 4:a33d2e24765a | 164 | if (TA8 == 1) { |
Enenkel | 4:a33d2e24765a | 165 | LedD2=1; |
Enenkel | 4:a33d2e24765a | 166 | } |
Enenkel | 4:a33d2e24765a | 167 | else { |
Enenkel | 4:a33d2e24765a | 168 | LedD2=0; |
Enenkel | 4:a33d2e24765a | 169 | } |
Enenkel | 4:a33d2e24765a | 170 | // |
Enenkel | 4:a33d2e24765a | 171 | ldrtest(); |
Enenkel | 4:a33d2e24765a | 172 | wait (0.01); |
Enenkel | 4:a33d2e24765a | 173 | |
Enenkel | 4:a33d2e24765a | 174 | } |
Enenkel | 4:a33d2e24765a | 175 | } |
Enenkel | 4:a33d2e24765a | 176 | //******************************************************************* |
Enenkel | 4:a33d2e24765a | 177 | void blueledtest() |
Enenkel | 4:a33d2e24765a | 178 | { |
Enenkel | 4:a33d2e24765a | 179 | a=0; |
Enenkel | 4:a33d2e24765a | 180 | while (a<10) |
Enenkel | 2:040855fee6fa | 181 | { |
Enenkel | 4:a33d2e24765a | 182 | BlueLed=1; |
Enenkel | 4:a33d2e24765a | 183 | wait (0.25); |
Enenkel | 4:a33d2e24765a | 184 | BlueLed=0; |
Enenkel | 4:a33d2e24765a | 185 | wait (0.25); |
Enenkel | 4:a33d2e24765a | 186 | a++; |
Enenkel | 4:a33d2e24765a | 187 | } |
Enenkel | 4:a33d2e24765a | 188 | |
Enenkel | 4:a33d2e24765a | 189 | |
Enenkel | 4:a33d2e24765a | 190 | } |
Enenkel | 4:a33d2e24765a | 191 | /*************** LDR TEST *******************************/ |
Enenkel | 4:a33d2e24765a | 192 | void ldrtest() |
Enenkel | 4:a33d2e24765a | 193 | { |
Enenkel | 4:a33d2e24765a | 194 | if(LDR <= 0.2) { |
Enenkel | 4:a33d2e24765a | 195 | LedD10=1; |
Enenkel | 4:a33d2e24765a | 196 | } |
Enenkel | 4:a33d2e24765a | 197 | else |
Enenkel | 4:a33d2e24765a | 198 | { |
Enenkel | 4:a33d2e24765a | 199 | LedD10=0; |
Enenkel | 4:a33d2e24765a | 200 | } |
Enenkel | 4:a33d2e24765a | 201 | |
Enenkel | 4:a33d2e24765a | 202 | if(LDR <= 0.07) { // Ab einer Lichtstärke von 0.15 oder kleiner |
Enenkel | 4:a33d2e24765a | 203 | LedD11 = 1; |
Enenkel | 4:a33d2e24765a | 204 | } // Ist die LED D1 EIN |
Enenkel | 4:a33d2e24765a | 205 | else { |
Enenkel | 4:a33d2e24765a | 206 | LedD11 = 0; |
Enenkel | 4:a33d2e24765a | 207 | } |
Enenkel | 4:a33d2e24765a | 208 | if (LDR <= 0.1) { |
Enenkel | 4:a33d2e24765a | 209 | LedD13=1; |
Enenkel | 4:a33d2e24765a | 210 | } |
Enenkel | 4:a33d2e24765a | 211 | else { |
Enenkel | 4:a33d2e24765a | 212 | LedD13=0; |
Enenkel | 4:a33d2e24765a | 213 | } |
Enenkel | 4:a33d2e24765a | 214 | if (LDR <= 0.15) { |
Enenkel | 4:a33d2e24765a | 215 | LedD12=1; |
Enenkel | 4:a33d2e24765a | 216 | } |
Enenkel | 4:a33d2e24765a | 217 | else { |
Enenkel | 4:a33d2e24765a | 218 | LedD12=0; |
Enenkel | 4:a33d2e24765a | 219 | } |
Enenkel | 4:a33d2e24765a | 220 | } |
Enenkel | 2:040855fee6fa | 221 | |
Enenkel | 4:a33d2e24765a | 222 | /********************** ENDE ******************************/ |