Rev 1.0

Dependencies:   BertlLib mbed

Fork of MotorTest by michael hollegha

Committer:
hollegha2
Date:
Tue Apr 21 08:04:54 2015 +0000
Revision:
3:78f03f96d641
Parent:
MotorTest.cpp@1:ef44156a6e44
Rev 1.0

Who changed what in which revision?

UserRevisionLine numberNew contents of line
hollegha2 1:ef44156a6e44 1
hollegha2 0:9ac39e20730c 2 #include "mbed.h"
hollegha2 0:9ac39e20730c 3 #include "Serial_HL.h"
hollegha2 1:ef44156a6e44 4 #include "Bertl14.h"
hollegha2 1:ef44156a6e44 5 #include "BertlObjects.h"
hollegha2 0:9ac39e20730c 6
hollegha2 3:78f03f96d641 7 void DriveUntilObstacle();
hollegha2 3:78f03f96d641 8 void Turn180();
hollegha2 0:9ac39e20730c 9
hollegha2 0:9ac39e20730c 10 int main(void)
hollegha2 0:9ac39e20730c 11 {
hollegha2 3:78f03f96d641 12 InitBertl();
hollegha2 1:ef44156a6e44 13 pex.ClearLeds();
hollegha2 3:78f03f96d641 14 // Damit der Roboter nicht gleich loskoffert
hollegha2 3:78f03f96d641 15 leds = 9;
hollegha2 3:78f03f96d641 16 pex.WaitUntilFrontButtonPressed();
hollegha2 3:78f03f96d641 17 leds=6;
hollegha2 3:78f03f96d641 18 wait(0.8);
hollegha2 3:78f03f96d641 19 pex.WaitUntilFrontButtonPressed();
hollegha2 3:78f03f96d641 20 leds=0;
hollegha2 3:78f03f96d641 21 // 2x Button-pressed jetzt gehts los
hollegha2 3:78f03f96d641 22
hollegha2 3:78f03f96d641 23 while(1) {
hollegha2 3:78f03f96d641 24 DriveUntilObstacle();
hollegha2 3:78f03f96d641 25 wait(0.5); // Debug wait
hollegha2 3:78f03f96d641 26 Turn180();
hollegha2 3:78f03f96d641 27 wait(0.5);
hollegha2 0:9ac39e20730c 28 }
hollegha2 0:9ac39e20730c 29
hollegha2 3:78f03f96d641 30 return 1;
hollegha2 0:9ac39e20730c 31 }
hollegha2 0:9ac39e20730c 32
hollegha2 0:9ac39e20730c 33
hollegha2 3:78f03f96d641 34 void DriveUntilObstacle()
hollegha2 3:78f03f96d641 35 {
hollegha2 3:78f03f96d641 36 // Motoren ein
hollegha2 3:78f03f96d641 37 // in einer While-Schleife warten bis Distanz kleiner MinDistance
hollegha2 3:78f03f96d641 38 // Motoren aus !!!
hollegha2 3:78f03f96d641 39 }
hollegha2 3:78f03f96d641 40
hollegha2 3:78f03f96d641 41 void Turn180()
hollegha2 3:78f03f96d641 42 {
hollegha2 3:78f03f96d641 43 // Motoren auf 0.5 bis 0.7
hollegha2 3:78f03f96d641 44 // in einer While-Schleife warten bis
hollegha2 3:78f03f96d641 45 // bei !!!beiden!!! Motoren die Ticks für eine 180° Drehung erreicht sind
hollegha2 3:78f03f96d641 46 // Motoren aus
hollegha2 3:78f03f96d641 47 }
hollegha2 3:78f03f96d641 48
hollegha2 3:78f03f96d641 49
hollegha2 3:78f03f96d641 50