Testet BERTL17 zuerst die LED's dann nach Tasterdruck jeweils die dazugehörigen LED
Dependencies: mbed
main.cpp@8:98b107c7790e, 2017-05-13 (annotated)
- Committer:
- Enenkel
- Date:
- Sat May 13 09:36:02 2017 +0000
- Revision:
- 8:98b107c7790e
- Parent:
- 6:1c5b466fbe55
B17_T1_12Von
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
Enenkel | 0:a8a0195ed7dc | 1 | /*********************************** |
Enenkel | 6:1c5b466fbe55 | 2 | name: BERTL16_Test1 24.4.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 | 5:8d00369f47e9 | 24 | DigitalOut LedD11 (P2_16); |
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 | 5:8d00369f47e9 | 65 | LedD1=LedD2=LedD4=LedD5=LedD6=LedD7=LedD8=LedD9=LedD10=LedD11=LedD12=LedD13=1; |
Enenkel | 4:a33d2e24765a | 66 | while (a<2) { // 2 Mal durch die Schleife laufen |
Enenkel | 4:a33d2e24765a | 67 | // Alle LED einmal blinken (2 Mal durchlaufen |
Enenkel | 5:8d00369f47e9 | 68 | LedD1=0; // LED D1 ON |
Enenkel | 4:a33d2e24765a | 69 | wait (0.5); // 0.5 sec warten |
Enenkel | 5:8d00369f47e9 | 70 | LedD1=1; // LED D1 AUS |
Enenkel | 5:8d00369f47e9 | 71 | LedD2=0; // LED D2 EIN |
Enenkel | 4:a33d2e24765a | 72 | wait (0.5); |
Enenkel | 5:8d00369f47e9 | 73 | LedD2=1; |
Enenkel | 4:a33d2e24765a | 74 | LedD4=0; |
Enenkel | 5:8d00369f47e9 | 75 | wait (0.5); |
Enenkel | 5:8d00369f47e9 | 76 | LedD4=1; |
Enenkel | 5:8d00369f47e9 | 77 | LedD5=0; |
Enenkel | 4:a33d2e24765a | 78 | wait (0.5); |
Enenkel | 5:8d00369f47e9 | 79 | LedD5=1; |
Enenkel | 5:8d00369f47e9 | 80 | LedD6=0; |
Enenkel | 5:8d00369f47e9 | 81 | wait (0.5); |
Enenkel | 4:a33d2e24765a | 82 | LedD6=1; |
Enenkel | 4:a33d2e24765a | 83 | LedD7=0; |
Enenkel | 5:8d00369f47e9 | 84 | wait (0.5); |
Enenkel | 5:8d00369f47e9 | 85 | LedD7=1; |
Enenkel | 5:8d00369f47e9 | 86 | LedD8=0; |
Enenkel | 4:a33d2e24765a | 87 | wait (0.5); |
Enenkel | 5:8d00369f47e9 | 88 | LedD8=1; |
Enenkel | 5:8d00369f47e9 | 89 | LedD9=0; |
Enenkel | 5:8d00369f47e9 | 90 | wait (0.5); |
Enenkel | 4:a33d2e24765a | 91 | LedD9=1; |
Enenkel | 4:a33d2e24765a | 92 | LedD10=0; |
Enenkel | 4:a33d2e24765a | 93 | wait (0.5); |
Enenkel | 5:8d00369f47e9 | 94 | LedD10=1; |
Enenkel | 4:a33d2e24765a | 95 | LedD11=0; |
Enenkel | 4:a33d2e24765a | 96 | wait (0.5); |
Enenkel | 5:8d00369f47e9 | 97 | LedD11=1; |
Enenkel | 5:8d00369f47e9 | 98 | LedD13=0; |
Enenkel | 5:8d00369f47e9 | 99 | wait (0.5); |
Enenkel | 4:a33d2e24765a | 100 | LedD13=1; |
Enenkel | 5:8d00369f47e9 | 101 | LedD12=0; |
Enenkel | 4:a33d2e24765a | 102 | wait (0.5); |
Enenkel | 5:8d00369f47e9 | 103 | LedD12=1; |
Enenkel | 4:a33d2e24765a | 104 | wait (0.5); |
Enenkel | 4:a33d2e24765a | 105 | |
Enenkel | 4:a33d2e24765a | 106 | b=0; |
Enenkel | 4:a33d2e24765a | 107 | while (b<2) // Alle LED blinken 2 Mal |
Enenkel | 4:a33d2e24765a | 108 | { |
Enenkel | 5:8d00369f47e9 | 109 | LedD1=LedD2=LedD4=LedD5=LedD6=LedD7=LedD8=LedD9=LedD10=LedD11=LedD12=LedD13=0; |
Enenkel | 4:a33d2e24765a | 110 | wait (0.5); |
Enenkel | 5:8d00369f47e9 | 111 | LedD1=LedD2=LedD4=LedD5=LedD6=LedD7=LedD8=LedD9=LedD10=LedD11=LedD12=LedD13=1; |
Enenkel | 4:a33d2e24765a | 112 | wait (0.5); |
Enenkel | 4:a33d2e24765a | 113 | b=b++; |
Enenkel | 4:a33d2e24765a | 114 | } |
Enenkel | 4:a33d2e24765a | 115 | a=a++; // a = a+1 -> in C besser a++ |
Enenkel | 4:a33d2e24765a | 116 | } |
Enenkel | 4:a33d2e24765a | 117 | } |
Enenkel | 2:040855fee6fa | 118 | |
Enenkel | 4:a33d2e24765a | 119 | // *************************************************************************** |
Enenkel | 4:a33d2e24765a | 120 | void tastertest() { //Taster Test Bei Drücken einer Taste leuchtet die LED ! |
Enenkel | 5:8d00369f47e9 | 121 | LedD1=LedD2=LedD4=LedD5=LedD6=LedD7=LedD8=LedD9=LedD10=LedD11=LedD12=LedD13=1; |
Enenkel | 4:a33d2e24765a | 122 | while(1) // läuft ewig weiter |
Enenkel | 4:a33d2e24765a | 123 | { |
Enenkel | 4:a33d2e24765a | 124 | if (TA1 == 1) { |
Enenkel | 4:a33d2e24765a | 125 | LedD10=LedD11=LedD12=LedD13=1; |
Enenkel | 4:a33d2e24765a | 126 | } |
Enenkel | 4:a33d2e24765a | 127 | else { |
Enenkel | 4:a33d2e24765a | 128 | LedD10=LedD11=LedD12=LedD13=0; |
Enenkel | 4:a33d2e24765a | 129 | } |
Enenkel | 4:a33d2e24765a | 130 | if (TA2 == 1) { |
Enenkel | 4:a33d2e24765a | 131 | LedD4=1; |
Enenkel | 4:a33d2e24765a | 132 | } |
Enenkel | 4:a33d2e24765a | 133 | else { |
Enenkel | 4:a33d2e24765a | 134 | LedD4=0; |
Enenkel | 4:a33d2e24765a | 135 | } |
Enenkel | 4:a33d2e24765a | 136 | if (TA3 == 1) { |
Enenkel | 4:a33d2e24765a | 137 | LedD1=1; |
Enenkel | 4:a33d2e24765a | 138 | } |
Enenkel | 4:a33d2e24765a | 139 | else { |
Enenkel | 4:a33d2e24765a | 140 | LedD1=0; |
Enenkel | 4:a33d2e24765a | 141 | } |
Enenkel | 4:a33d2e24765a | 142 | if (TA4 == 1) { |
Enenkel | 4:a33d2e24765a | 143 | LedD6=LedD8=1; |
Enenkel | 4:a33d2e24765a | 144 | } |
Enenkel | 4:a33d2e24765a | 145 | else { |
Enenkel | 4:a33d2e24765a | 146 | LedD6=LedD8=0; |
Enenkel | 4:a33d2e24765a | 147 | } |
Enenkel | 4:a33d2e24765a | 148 | if (TA5 == 1) { |
Enenkel | 4:a33d2e24765a | 149 | LedD7=1; |
Enenkel | 4:a33d2e24765a | 150 | } |
Enenkel | 4:a33d2e24765a | 151 | else { |
Enenkel | 4:a33d2e24765a | 152 | LedD7=0; |
Enenkel | 4:a33d2e24765a | 153 | } |
Enenkel | 4:a33d2e24765a | 154 | if (TA6 == 1) { |
Enenkel | 4:a33d2e24765a | 155 | LedD9=1; |
Enenkel | 4:a33d2e24765a | 156 | } |
Enenkel | 4:a33d2e24765a | 157 | else { |
Enenkel | 4:a33d2e24765a | 158 | LedD9=0; |
Enenkel | 4:a33d2e24765a | 159 | } |
Enenkel | 4:a33d2e24765a | 160 | if (TA7 == 1) { |
Enenkel | 4:a33d2e24765a | 161 | LedD5=1; |
Enenkel | 4:a33d2e24765a | 162 | } |
Enenkel | 4:a33d2e24765a | 163 | else { |
Enenkel | 4:a33d2e24765a | 164 | LedD5=0; |
Enenkel | 4:a33d2e24765a | 165 | } |
Enenkel | 4:a33d2e24765a | 166 | if (TA8 == 1) { |
Enenkel | 4:a33d2e24765a | 167 | LedD2=1; |
Enenkel | 4:a33d2e24765a | 168 | } |
Enenkel | 4:a33d2e24765a | 169 | else { |
Enenkel | 4:a33d2e24765a | 170 | LedD2=0; |
Enenkel | 4:a33d2e24765a | 171 | } |
Enenkel | 4:a33d2e24765a | 172 | // |
Enenkel | 5:8d00369f47e9 | 173 | //ldrtest(); |
Enenkel | 4:a33d2e24765a | 174 | wait (0.01); |
Enenkel | 4:a33d2e24765a | 175 | |
Enenkel | 4:a33d2e24765a | 176 | } |
Enenkel | 4:a33d2e24765a | 177 | } |
Enenkel | 4:a33d2e24765a | 178 | //******************************************************************* |
Enenkel | 5:8d00369f47e9 | 179 | void blueledtest() //needs 5V |
Enenkel | 4:a33d2e24765a | 180 | { |
Enenkel | 4:a33d2e24765a | 181 | a=0; |
Enenkel | 4:a33d2e24765a | 182 | while (a<10) |
Enenkel | 2:040855fee6fa | 183 | { |
Enenkel | 4:a33d2e24765a | 184 | BlueLed=1; |
Enenkel | 4:a33d2e24765a | 185 | wait (0.25); |
Enenkel | 4:a33d2e24765a | 186 | BlueLed=0; |
Enenkel | 4:a33d2e24765a | 187 | wait (0.25); |
Enenkel | 4:a33d2e24765a | 188 | a++; |
Enenkel | 4:a33d2e24765a | 189 | } |
Enenkel | 4:a33d2e24765a | 190 | |
Enenkel | 4:a33d2e24765a | 191 | |
Enenkel | 4:a33d2e24765a | 192 | } |
Enenkel | 4:a33d2e24765a | 193 | /*************** LDR TEST *******************************/ |
Enenkel | 4:a33d2e24765a | 194 | void ldrtest() |
Enenkel | 4:a33d2e24765a | 195 | { |
Enenkel | 4:a33d2e24765a | 196 | if(LDR <= 0.2) { |
Enenkel | 5:8d00369f47e9 | 197 | LedD10=0; |
Enenkel | 4:a33d2e24765a | 198 | } |
Enenkel | 4:a33d2e24765a | 199 | else |
Enenkel | 4:a33d2e24765a | 200 | { |
Enenkel | 5:8d00369f47e9 | 201 | LedD10=1; |
Enenkel | 4:a33d2e24765a | 202 | } |
Enenkel | 4:a33d2e24765a | 203 | |
Enenkel | 4:a33d2e24765a | 204 | if(LDR <= 0.07) { // Ab einer Lichtstärke von 0.15 oder kleiner |
Enenkel | 5:8d00369f47e9 | 205 | LedD11 = 0; |
Enenkel | 4:a33d2e24765a | 206 | } // Ist die LED D1 EIN |
Enenkel | 4:a33d2e24765a | 207 | else { |
Enenkel | 5:8d00369f47e9 | 208 | LedD11 = 1; |
Enenkel | 4:a33d2e24765a | 209 | } |
Enenkel | 4:a33d2e24765a | 210 | if (LDR <= 0.1) { |
Enenkel | 5:8d00369f47e9 | 211 | LedD13=0; |
Enenkel | 5:8d00369f47e9 | 212 | } |
Enenkel | 5:8d00369f47e9 | 213 | else { |
Enenkel | 4:a33d2e24765a | 214 | LedD13=1; |
Enenkel | 4:a33d2e24765a | 215 | } |
Enenkel | 4:a33d2e24765a | 216 | if (LDR <= 0.15) { |
Enenkel | 5:8d00369f47e9 | 217 | LedD12=0; |
Enenkel | 4:a33d2e24765a | 218 | } |
Enenkel | 4:a33d2e24765a | 219 | else { |
Enenkel | 5:8d00369f47e9 | 220 | LedD12=1; |
Enenkel | 4:a33d2e24765a | 221 | } |
Enenkel | 4:a33d2e24765a | 222 | } |
Enenkel | 2:040855fee6fa | 223 | |
Enenkel | 4:a33d2e24765a | 224 | /********************** ENDE ******************************/ |