Dominik Sukic
/
BERTL14_LINESENSOR
Linesensor
Fork of BERTL14_LINESENSOR by
Revision 1:9e097feb3b19, committed 2015-06-17
- Comitter:
- DomiSukic
- Date:
- Wed Jun 17 14:10:02 2015 +0000
- Parent:
- 0:acfdc7c80165
- Commit message:
- Linesensor Sukic/Riffnaller/Wummbauer
Changed in this revision
main.cpp | Show annotated file Show diff for this revision Revisions of this file |
--- a/main.cpp Tue May 20 06:59:40 2014 +0000 +++ b/main.cpp Wed Jun 17 14:10:02 2015 +0000 @@ -1,23 +1,79 @@ -/*********************************** -name: BERTL14_LINESENSOR -author: Wolfgang Raimann -email: rai@bulme.at -description: - Die vier Sensoren auf der Unterseite werden auf die LEDs D10-D13 durchgeschaltet -***********************************/ #include "mbed.h" DigitalOut myled(LED1); +DigitalOut MotorL_EN(p34); +DigitalOut MotorL_FORWARD(P1_0); +DigitalOut MotorL_REVERSE(P1_1); + +DigitalOut MotorR_EN(p36); +DigitalOut MotorR_FORWARD(P1_3); +DigitalOut MotorR_REVERSE(P1_4); BusIn linesensor(p18, p16, p19, p17); BusOut leds(LED1, LED2, LED3, LED4); -int main() { - while(1) { +int main() +{ +while (1) +{ + leds = linesensor; + + while (linesensor == 0x0) + { + MotorL_FORWARD = 0; + MotorR_REVERSE = 0; + MotorL_REVERSE = 1; + MotorR_FORWARD = 1; + MotorL_EN = 1; + MotorR_EN = 1; + + leds = linesensor; + } + + while (linesensor == 0xC || linesensor == 0x8) + { + MotorL_FORWARD = 0; + MotorR_FORWARD = 0; + MotorL_REVERSE = 1; + MotorR_REVERSE = 1; + MotorL_EN = 1; + MotorR_EN = 1; + + wait (0.3); + leds = linesensor; - } + } + + while (linesensor == 0x3 || linesensor == 0x1) + { + MotorL_FORWARD = 1; + MotorR_FORWARD = 1; + MotorL_REVERSE = 0; + MotorR_REVERSE = 0; + MotorL_EN = 1; + MotorR_EN = 1; + + wait (0.3); + + leds = linesensor; + } + + while (linesensor == 0x6) + { + MotorL_FORWARD = 1; + MotorR_REVERSE = 1; + MotorL_REVERSE = 0; + MotorR_FORWARD = 0; + MotorL_EN = 1; + MotorR_EN = 1; + + leds = linesensor; + } + } +} +