Geschwindigkeit kann nun geändert werden
Dependencies: mbed
Diff: main.cpp
- Revision:
- 5:f6930387a28e
- Parent:
- 4:2bf2ab6a1163
- Child:
- 6:dc02e3e244e6
diff -r 2bf2ab6a1163 -r f6930387a28e main.cpp --- a/main.cpp Fri May 13 13:17:34 2016 +0000 +++ b/main.cpp Wed May 25 07:42:17 2016 +0000 @@ -14,13 +14,16 @@ #include "mbed.h" // ************ DEKLARATIONEN ************** -DigitalOut Von (P2_13); // Motor Spannung ab BERTL15 nötig ! -DigitalOut MotorL_EN(P1_19); // Enable OB DIE LINKS ODER RECHTS IST NOCH NICHT KLAR ! -DigitalOut MotorL_FORWARD(P2_15); // Forwerts -DigitalOut MotorL_REVERSE(P2_14); // Rückwerts +DigitalOut Von (P2_13); -DigitalOut MotorR_EN(P2_19); //Die Leitung führt zum Pin PO_21 am Prozessor -DigitalOut MotorR_FORWARD(P2_20); //Die Leitung führt zum Pin P1_3 am Prozessor +PwmOut MotorL (P1_19); +DigitalOut MotorL_EN(P1_19); +DigitalOut MotorL_FORWARD(P2_15); +DigitalOut MotorL_REVERSE(P2_14); + +PwmOut MotorR (P2_19); +DigitalOut MotorR_EN(P2_19); +DigitalOut MotorR_FORWARD(P2_20); DigitalOut MotorR_REVERSE(P2_21); @@ -46,83 +49,99 @@ DigitalOut TA1 (P1_23); Von=1; MotorR_EN=MotorL_EN=1; - int a; - a=0; - while(a<4) { + //int a; + //a=0; + while(1) { + MotorL= (0.75); //Bereich zwischen 1 und 0 stellt dei Geschwindigkeit ein. + MotorR= (1); //Bereich zwischen 1 und 0 stellt dei Geschwindigkeit ein. + if(TA1==1) + { + MotorL_REVERSE=1; + MotorR_REVERSE=1; + wait(2.0); + MotorR_REVERSE=0; + MotorL_REVERSE=0; + wait (0.5); + + MotorR_REVERSE=1; + MotorL_FORWARD=1; + wait (0.25); + MotorR_REVERSE=0; + MotorL_FORWARD=0; + } - - - - int b; - //int c; - int d; - - LED1=LED2=LED4=LED5=LED6=LED7=LED8=LED9=LED10=LED11=LED12=LED13=LED20=LED24=1; - LED1=LED4=0; - LED20=LED24=0; - MotorL_FORWARD = 1; - MotorR_FORWARD = 1; - - wait (7.0); - - MotorL_FORWARD = 0; - MotorR_FORWARD = 0; - - LED1=LED4=1; - LED7=LED9=0; - b=0; - while (b<2) { - LED8=0; - LED5=0; + else + { + int b; + //int c; + int d; + + LED1=LED2=LED4=LED5=LED6=LED7=LED8=LED9=LED10=LED11=LED12=LED13=LED20=LED24=1; + LED1=LED4=0; + LED20=LED24=0; + MotorL_FORWARD = 1; + MotorR_FORWARD = 1; + + wait (7.0); + + MotorL_FORWARD = 0; + MotorR_FORWARD = 0; + + LED1=LED4=1; + LED7=LED9=0; + b=0; + while (b<2) { + LED8=0; + LED5=0; + wait (0.5); + LED5=1; + LED8=1; + wait (0.5); + b=b++; + } + + + + MotorL_FORWARD =1; + MotorR_REVERSE =1; + wait (0.25); + MotorL_FORWARD = 0; + MotorR_REVERSE = 0; + wait (2.0); + LED7=LED9= 1; + + LED1=LED4=0; + MotorL_FORWARD=1; + MotorR_FORWARD=1; + wait (4.0); + MotorL_FORWARD=0; + MotorR_FORWARD=0; + wait (0.0); + LED1=LED4=1; + + LED7=LED9=0; + + d=0; + while(d<2) { + LED8=LED5=0; + wait (0.5); + LED8=LED5=1; + wait (0.5); + d=d++; + } + MotorL_FORWARD=1; + MotorR_REVERSE=1; + wait (0.25); + MotorL_FORWARD=0; + MotorR_REVERSE=0; wait (0.5); - LED5=1; - LED8=1; - wait (0.5); - b=b++; + LED7=LED9=1; + LED1=LED4=LED20=LED24=0; } - - - MotorL_FORWARD =1; - MotorR_REVERSE =1; - wait (0.25); - MotorL_FORWARD = 0; - MotorR_REVERSE = 0; - wait (2.0); - LED7=LED9= 1; - - LED1=LED4=0; - MotorL_FORWARD=1; - MotorR_FORWARD=1; - wait (4.0); - MotorL_FORWARD=0; - MotorR_FORWARD=0; - wait (0.0); - LED1=LED4=1; - - LED7=LED9=0; + - d=0; - while(d<2) { - LED8=LED5=0; - wait (0.5); - LED8=LED5=1; - wait (0.5); - d=d++; - } - MotorL_FORWARD=1; - MotorR_REVERSE=1; - wait (0.25); - MotorL_FORWARD=0; - MotorR_REVERSE=0; - wait (0.5); - LED7=LED9=1; - LED1=LED4=LED20=LED24=0; - - - - - a=a++; + //a=a++; } }