LauflichtBalken
LaufLichtBalken.cpp@0:ae6cd9d52dc9, 2018-06-20 (annotated)
- Committer:
- martwerl
- Date:
- Wed Jun 20 14:27:30 2018 +0000
- Revision:
- 0:ae6cd9d52dc9
LauflichtBalken
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
martwerl | 0:ae6cd9d52dc9 | 1 | #include "mbed.h" |
martwerl | 0:ae6cd9d52dc9 | 2 | #include "LaufLichtBalken.h" |
martwerl | 0:ae6cd9d52dc9 | 3 | |
martwerl | 0:ae6cd9d52dc9 | 4 | /********Beispiel 1********************* |
martwerl | 0:ae6cd9d52dc9 | 5 | ledOn() // beide Leds einschalten |
martwerl | 0:ae6cd9d52dc9 | 6 | ledOff() // beide Leds ausschalten |
martwerl | 0:ae6cd9d52dc9 | 7 | ledX() // beide Leds gegengleich schalten |
martwerl | 0:ae6cd9d52dc9 | 8 | printStatus() // Anzeigen ob Leds ein oder aus |
martwerl | 0:ae6cd9d52dc9 | 9 | ******************************/ |
martwerl | 0:ae6cd9d52dc9 | 10 | |
martwerl | 0:ae6cd9d52dc9 | 11 | /***********Beispiel 3********************** |
martwerl | 0:ae6cd9d52dc9 | 12 | * //lauflichtbalken() |
martwerl | 0:ae6cd9d52dc9 | 13 | D1 D2 D3 D4 |
martwerl | 0:ae6cd9d52dc9 | 14 | - - - - Ein Durchgang dauert 2 sec |
martwerl | 0:ae6cd9d52dc9 | 15 | X - - - |
martwerl | 0:ae6cd9d52dc9 | 16 | X X - - |
martwerl | 0:ae6cd9d52dc9 | 17 | X X X - |
martwerl | 0:ae6cd9d52dc9 | 18 | X X X X |
martwerl | 0:ae6cd9d52dc9 | 19 | - - - - |
martwerl | 0:ae6cd9d52dc9 | 20 | X X X X X=ON - = off |
martwerl | 0:ae6cd9d52dc9 | 21 | **********************************/ |
martwerl | 0:ae6cd9d52dc9 | 22 | |
martwerl | 0:ae6cd9d52dc9 | 23 | |
martwerl | 0:ae6cd9d52dc9 | 24 | |
martwerl | 0:ae6cd9d52dc9 | 25 | |
martwerl | 0:ae6cd9d52dc9 | 26 | |
martwerl | 0:ae6cd9d52dc9 | 27 | |
martwerl | 0:ae6cd9d52dc9 | 28 | void LaufLichtBalken::ledOff(void) |
martwerl | 0:ae6cd9d52dc9 | 29 | { |
martwerl | 0:ae6cd9d52dc9 | 30 | _pin=0; |
martwerl | 0:ae6cd9d52dc9 | 31 | _pin2=0; |
martwerl | 0:ae6cd9d52dc9 | 32 | _pin3=0; |
martwerl | 0:ae6cd9d52dc9 | 33 | _pin4=0; |
martwerl | 0:ae6cd9d52dc9 | 34 | } |
martwerl | 0:ae6cd9d52dc9 | 35 | |
martwerl | 0:ae6cd9d52dc9 | 36 | void LaufLichtBalken::ledOn1(void) |
martwerl | 0:ae6cd9d52dc9 | 37 | { |
martwerl | 0:ae6cd9d52dc9 | 38 | _pin=1; |
martwerl | 0:ae6cd9d52dc9 | 39 | _pin2=0; |
martwerl | 0:ae6cd9d52dc9 | 40 | _pin3=0; |
martwerl | 0:ae6cd9d52dc9 | 41 | _pin4=0; |
martwerl | 0:ae6cd9d52dc9 | 42 | } |
martwerl | 0:ae6cd9d52dc9 | 43 | |
martwerl | 0:ae6cd9d52dc9 | 44 | void LaufLichtBalken::ledOn2(void) |
martwerl | 0:ae6cd9d52dc9 | 45 | { |
martwerl | 0:ae6cd9d52dc9 | 46 | _pin=1; |
martwerl | 0:ae6cd9d52dc9 | 47 | _pin2=1; |
martwerl | 0:ae6cd9d52dc9 | 48 | _pin3=0; |
martwerl | 0:ae6cd9d52dc9 | 49 | _pin4=0; |
martwerl | 0:ae6cd9d52dc9 | 50 | } |
martwerl | 0:ae6cd9d52dc9 | 51 | |
martwerl | 0:ae6cd9d52dc9 | 52 | void LaufLichtBalken::ledOn3(void) |
martwerl | 0:ae6cd9d52dc9 | 53 | { |
martwerl | 0:ae6cd9d52dc9 | 54 | _pin=1; |
martwerl | 0:ae6cd9d52dc9 | 55 | _pin2=1; |
martwerl | 0:ae6cd9d52dc9 | 56 | _pin3=1; |
martwerl | 0:ae6cd9d52dc9 | 57 | _pin4=0; |
martwerl | 0:ae6cd9d52dc9 | 58 | } |
martwerl | 0:ae6cd9d52dc9 | 59 | |
martwerl | 0:ae6cd9d52dc9 | 60 | void LaufLichtBalken::ledOn4(void) |
martwerl | 0:ae6cd9d52dc9 | 61 | { |
martwerl | 0:ae6cd9d52dc9 | 62 | _pin=1; |
martwerl | 0:ae6cd9d52dc9 | 63 | _pin2=1; |
martwerl | 0:ae6cd9d52dc9 | 64 | _pin3=1; |
martwerl | 0:ae6cd9d52dc9 | 65 | _pin4=1; |
martwerl | 0:ae6cd9d52dc9 | 66 | } |
martwerl | 0:ae6cd9d52dc9 | 67 | |
martwerl | 0:ae6cd9d52dc9 | 68 | void LaufLichtBalken::printStatus(void) |
martwerl | 0:ae6cd9d52dc9 | 69 | { |
martwerl | 0:ae6cd9d52dc9 | 70 | printf("Status Read:\nLED1 is now %d\nLED2 is now %d\nLED1 is now %d\nLED1 is now %d\n\n", _pin.read(), _pin2.read(), _pin3.read(), _pin4.read()); |
martwerl | 0:ae6cd9d52dc9 | 71 | } |
martwerl | 0:ae6cd9d52dc9 | 72 | |
martwerl | 0:ae6cd9d52dc9 | 73 | |
martwerl | 0:ae6cd9d52dc9 | 74 | |
martwerl | 0:ae6cd9d52dc9 | 75 |