![](/media/cache/profiles/9ddc70b3617c3e65c03fa63c230a1705.50x50_q85.jpg)
FET10 UNIMOG
main.cpp@0:d6a1ad1d68e7, 2012-03-10 (annotated)
- Committer:
- wango
- Date:
- Sat Mar 10 11:34:43 2012 +0000
- Revision:
- 0:d6a1ad1d68e7
FET10 UNIMOG
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
wango | 0:d6a1ad1d68e7 | 1 | #include "mbed.h" |
wango | 0:d6a1ad1d68e7 | 2 | #include "Servo.h" |
wango | 0:d6a1ad1d68e7 | 3 | |
wango | 0:d6a1ad1d68e7 | 4 | |
wango | 0:d6a1ad1d68e7 | 5 | |
wango | 0:d6a1ad1d68e7 | 6 | |
wango | 0:d6a1ad1d68e7 | 7 | DigitalIn Hupen(p10); |
wango | 0:d6a1ad1d68e7 | 8 | DigitalIn blinker_links(p11); |
wango | 0:d6a1ad1d68e7 | 9 | DigitalIn blinker_rechts(p12); |
wango | 0:d6a1ad1d68e7 | 10 | DigitalIn Scheinwerfer(p13); |
wango | 0:d6a1ad1d68e7 | 11 | DigitalIn Bremsleuchten(p14); |
wango | 0:d6a1ad1d68e7 | 12 | DigitalIn Seilwinde_hoch(p8); |
wango | 0:d6a1ad1d68e7 | 13 | DigitalIn Seilwinde_runter(p9); |
wango | 0:d6a1ad1d68e7 | 14 | |
wango | 0:d6a1ad1d68e7 | 15 | |
wango | 0:d6a1ad1d68e7 | 16 | DigitalOut Hupe (LED1); |
wango | 0:d6a1ad1d68e7 | 17 | DigitalOut bli (p19); |
wango | 0:d6a1ad1d68e7 | 18 | DigitalOut blir (p20); |
wango | 0:d6a1ad1d68e7 | 19 | DigitalOut Schein(LED4); |
wango | 0:d6a1ad1d68e7 | 20 | DigitalOut Brems (p5); |
wango | 0:d6a1ad1d68e7 | 21 | |
wango | 0:d6a1ad1d68e7 | 22 | |
wango | 0:d6a1ad1d68e7 | 23 | Servo Seilwinde(p21); |
wango | 0:d6a1ad1d68e7 | 24 | |
wango | 0:d6a1ad1d68e7 | 25 | int main() { |
wango | 0:d6a1ad1d68e7 | 26 | float range = 0.0005; |
wango | 0:d6a1ad1d68e7 | 27 | float position = 0.5; |
wango | 0:d6a1ad1d68e7 | 28 | Seilwinde.calibrate(range, 45.0); |
wango | 0:d6a1ad1d68e7 | 29 | |
wango | 0:d6a1ad1d68e7 | 30 | while (1) { |
wango | 0:d6a1ad1d68e7 | 31 | |
wango | 0:d6a1ad1d68e7 | 32 | // Seilwinde |
wango | 0:d6a1ad1d68e7 | 33 | position = 0.5; |
wango | 0:d6a1ad1d68e7 | 34 | |
wango | 0:d6a1ad1d68e7 | 35 | if (( Seilwinde_hoch) & (!Seilwinde_runter)) |
wango | 0:d6a1ad1d68e7 | 36 | position = 0.3; |
wango | 0:d6a1ad1d68e7 | 37 | |
wango | 0:d6a1ad1d68e7 | 38 | if ((!Seilwinde_hoch) & ( Seilwinde_runter)) |
wango | 0:d6a1ad1d68e7 | 39 | position = 0.9; |
wango | 0:d6a1ad1d68e7 | 40 | |
wango | 0:d6a1ad1d68e7 | 41 | Seilwinde = position; |
wango | 0:d6a1ad1d68e7 | 42 | //--------------------------------------------------------------------- |
wango | 0:d6a1ad1d68e7 | 43 | |
wango | 0:d6a1ad1d68e7 | 44 | //Blinker rechts |
wango | 0:d6a1ad1d68e7 | 45 | |
wango | 0:d6a1ad1d68e7 | 46 | if (blinker_rechts) |
wango | 0:d6a1ad1d68e7 | 47 | blir = !blir; |
wango | 0:d6a1ad1d68e7 | 48 | |
wango | 0:d6a1ad1d68e7 | 49 | wait(0.25); |
wango | 0:d6a1ad1d68e7 | 50 | |
wango | 0:d6a1ad1d68e7 | 51 | if (!blinker_rechts) |
wango | 0:d6a1ad1d68e7 | 52 | blir = 0; |
wango | 0:d6a1ad1d68e7 | 53 | |
wango | 0:d6a1ad1d68e7 | 54 | //---------------------------------------------------------------------- |
wango | 0:d6a1ad1d68e7 | 55 | |
wango | 0:d6a1ad1d68e7 | 56 | // BLINKER LINKS TASTGRAD 0.5 |
wango | 0:d6a1ad1d68e7 | 57 | if (blinker_links) |
wango | 0:d6a1ad1d68e7 | 58 | bli = !bli; |
wango | 0:d6a1ad1d68e7 | 59 | |
wango | 0:d6a1ad1d68e7 | 60 | wait(0.25); |
wango | 0:d6a1ad1d68e7 | 61 | |
wango | 0:d6a1ad1d68e7 | 62 | if (!blinker_links) |
wango | 0:d6a1ad1d68e7 | 63 | bli = 0; |
wango | 0:d6a1ad1d68e7 | 64 | //--------------------------------------------------------------------- |
wango | 0:d6a1ad1d68e7 | 65 | |
wango | 0:d6a1ad1d68e7 | 66 | // Hupe |
wango | 0:d6a1ad1d68e7 | 67 | |
wango | 0:d6a1ad1d68e7 | 68 | if(Hupen) |
wango | 0:d6a1ad1d68e7 | 69 | Hupe=Hupen; |
wango | 0:d6a1ad1d68e7 | 70 | |
wango | 0:d6a1ad1d68e7 | 71 | //---------------------------------------------------------------------- |
wango | 0:d6a1ad1d68e7 | 72 | // Bremsleuchten |
wango | 0:d6a1ad1d68e7 | 73 | if(Bremsleuchten) |
wango | 0:d6a1ad1d68e7 | 74 | Brems=Bremsleuchten; |
wango | 0:d6a1ad1d68e7 | 75 | |
wango | 0:d6a1ad1d68e7 | 76 | if(!Bremsleuchten) |
wango | 0:d6a1ad1d68e7 | 77 | Brems=0; |
wango | 0:d6a1ad1d68e7 | 78 | |
wango | 0:d6a1ad1d68e7 | 79 | //---------------------------------------------------------------------- |
wango | 0:d6a1ad1d68e7 | 80 | // SCHEINWERFER |
wango | 0:d6a1ad1d68e7 | 81 | if(Scheinwerfer) |
wango | 0:d6a1ad1d68e7 | 82 | Schein= Scheinwerfer; |
wango | 0:d6a1ad1d68e7 | 83 | |
wango | 0:d6a1ad1d68e7 | 84 | |
wango | 0:d6a1ad1d68e7 | 85 | |
wango | 0:d6a1ad1d68e7 | 86 | |
wango | 0:d6a1ad1d68e7 | 87 | } |
wango | 0:d6a1ad1d68e7 | 88 | |
wango | 0:d6a1ad1d68e7 | 89 | } |