![](/media/cache/group/bulme_EKI4vU7.gif.50x50_q85.jpg)
RGB Ampel
Dependencies: mbed
Fork of _B14_Lektion05b by
main.cpp@3:6a11832bb176, 2015-03-20 (annotated)
- Committer:
- Enenkel
- Date:
- Fri Mar 20 10:44:18 2015 +0000
- Revision:
- 3:6a11832bb176
- Parent:
- 2:1e32590010a9
AMPEL
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
Enenkel | 0:c2a3df878b8a | 1 | /*********************************** |
Enenkel | 3:6a11832bb176 | 2 | name: _B14_Lektion05b AMPEL |
Enenkel | 2:1e32590010a9 | 3 | author: Gottfried Enenkel HTL BULME |
Enenkel | 2:1e32590010a9 | 4 | date : 17.3.2015 |
Enenkel | 2:1e32590010a9 | 5 | Aufgabe:: |
Enenkel | 0:c2a3df878b8a | 6 | 3 Blaue LEDs ON |
Enenkel | 0:c2a3df878b8a | 7 | Die RGB LED leuchtet rot grün blau |
Enenkel | 0:c2a3df878b8a | 8 | je 1 sec |
Enenkel | 3:6a11832bb176 | 9 | Ändere die Software so das eine AMPEL entsteht: |
Enenkel | 3:6a11832bb176 | 10 | rot 5 sec |
Enenkel | 3:6a11832bb176 | 11 | gelb 1 sec (rot und grün) |
Enenkel | 3:6a11832bb176 | 12 | grün 4 sec |
Enenkel | 3:6a11832bb176 | 13 | grün 3x blinken je 0,4 sec |
Enenkel | 3:6a11832bb176 | 14 | gelb grün 2 sec |
Enenkel | 0:c2a3df878b8a | 15 | ***********************************/ |
Enenkel | 0:c2a3df878b8a | 16 | #include "mbed.h" |
Enenkel | 0:c2a3df878b8a | 17 | // ************ DEKLARATIONEN ************** |
Enenkel | 0:c2a3df878b8a | 18 | DigitalOut LED_blue(P1_28); // Alle Blauen LED gehen auf einen Anschluß |
Enenkel | 0:c2a3df878b8a | 19 | // P1..Port1 _28 Anschluß 28 |
Enenkel | 0:c2a3df878b8a | 20 | DigitalOut RGB_bl(P1_24); // BLAU |
Enenkel | 0:c2a3df878b8a | 21 | // am uP -> P1..Port1 |
Enenkel | 0:c2a3df878b8a | 22 | // -> 24..IO Anschluss 24 |
Enenkel | 0:c2a3df878b8a | 23 | DigitalOut RGB_rt(P1_23); // ROT |
Enenkel | 0:c2a3df878b8a | 24 | DigitalOut RGB_gr(P1_25); // GRÜN P26 geht zum uP Port P1_25 |
Enenkel | 0:c2a3df878b8a | 25 | |
Enenkel | 0:c2a3df878b8a | 26 | // ************ HAUPT PROGRAMM ************** |
Enenkel | 0:c2a3df878b8a | 27 | int main() { |
Enenkel | 0:c2a3df878b8a | 28 | RGB_bl=1; //blau AUS |
Enenkel | 0:c2a3df878b8a | 29 | RGB_rt=1; //rot |
Enenkel | 0:c2a3df878b8a | 30 | RGB_gr=1; //grün |
Enenkel | 0:c2a3df878b8a | 31 | |
Enenkel | 0:c2a3df878b8a | 32 | while(1) { |
Enenkel | 0:c2a3df878b8a | 33 | LED_blue=1; //blaue LED AUS! |
Enenkel | 0:c2a3df878b8a | 34 | wait(1); |
Enenkel | 0:c2a3df878b8a | 35 | LED_blue=0; //blaue LED EIN |
Enenkel | 0:c2a3df878b8a | 36 | RGB_bl=0; //blau |
Enenkel | 0:c2a3df878b8a | 37 | wait(1); |
Enenkel | 0:c2a3df878b8a | 38 | RGB_bl=1; |
Enenkel | 0:c2a3df878b8a | 39 | RGB_gr=0; //grün |
Enenkel | 0:c2a3df878b8a | 40 | wait(1); |
Enenkel | 0:c2a3df878b8a | 41 | RGB_gr=1; |
Enenkel | 0:c2a3df878b8a | 42 | RGB_rt=0; //rot |
Enenkel | 0:c2a3df878b8a | 43 | wait(1); |
Enenkel | 0:c2a3df878b8a | 44 | RGB_rt=1; |
Enenkel | 0:c2a3df878b8a | 45 | wait(1); |
Enenkel | 0:c2a3df878b8a | 46 | } |
Enenkel | 0:c2a3df878b8a | 47 | } |
Enenkel | 0:c2a3df878b8a | 48 | |
Enenkel | 0:c2a3df878b8a | 49 | // ***************** ENDE ******************** |