Liniensensor_Bendel

Dependencies:   BertlLib mbed

Fork of BertlTemplate2 by michael hollegha

Committer:
Lippi
Date:
Mon Apr 11 15:47:47 2016 +0000
Revision:
4:c157810a12c5
Parent:
3:b6754e794335
Bertl 5sens

Who changed what in which revision?

UserRevisionLine numberNew contents of line
Lippi 3:b6754e794335 1
Lippi 3:b6754e794335 2 #include "mbed.h"
Lippi 3:b6754e794335 3 #include "Serial_HL.h"
Lippi 3:b6754e794335 4 #include "Bertl14.h"
Lippi 3:b6754e794335 5 #include "BertlObjects.h"
Lippi 3:b6754e794335 6
Lippi 3:b6754e794335 7 // main=2^0 LS ENC 2^2
Lippi 3:b6754e794335 8 BusOut boardPow(p30, P1_6, P1_7);
Lippi 3:b6754e794335 9 Timer t1, t2;
Lippi 3:b6754e794335 10 AnalogInHL ls1(p18), ls2(p16), ls3(p20), ls4(p19), ls5(p17);
Lippi 3:b6754e794335 11
Lippi 4:c157810a12c5 12 void FollowUntilEnd ();
Lippi 4:c157810a12c5 13 void TurnUntilLine();
Lippi 3:b6754e794335 14 int main(void)
Lippi 3:b6754e794335 15 {
Lippi 4:c157810a12c5 16 pex.WaitUntilFrontButtonPressed();
Lippi 3:b6754e794335 17 boardPow=3;
Lippi 3:b6754e794335 18 wait_ms(10);
Lippi 3:b6754e794335 19 InitBertl();
Lippi 3:b6754e794335 20 pex.useISR=0;
Lippi 3:b6754e794335 21 leds=9;
Lippi 3:b6754e794335 22 pex.ClearLeds();
Lippi 3:b6754e794335 23
Lippi 4:c157810a12c5 24 while(1)
Lippi 4:c157810a12c5 25 {
Lippi 4:c157810a12c5 26 if (ls1.Read()>400 ) {
Lippi 4:c157810a12c5 27 mL.SetPow(0.0);
Lippi 4:c157810a12c5 28 mR.SetPow(0.25);
Lippi 4:c157810a12c5 29
Lippi 3:b6754e794335 30 }
Lippi 4:c157810a12c5 31 else{
Lippi 4:c157810a12c5 32 if (ls5.Read()>400) {
Lippi 4:c157810a12c5 33 mL.SetPow(0.25);
Lippi 4:c157810a12c5 34 mR.SetPow(0.0);
Lippi 4:c157810a12c5 35 }
Lippi 4:c157810a12c5 36 else{
Lippi 4:c157810a12c5 37 if (ls3.Read()>400 && ls4.Read()>400 && ls2.Read()>400) {
Lippi 4:c157810a12c5 38 mL.SetPow(0.25);
Lippi 4:c157810a12c5 39 mR.SetPow(0.25);
Lippi 4:c157810a12c5 40 }
Lippi 4:c157810a12c5 41 }
Lippi 4:c157810a12c5 42 }
Lippi 4:c157810a12c5 43
Lippi 4:c157810a12c5 44 return;
Lippi 4:c157810a12c5 45
Lippi 4:c157810a12c5 46 //wait_ms(1000);
Lippi 4:c157810a12c5 47 //FollowUntilEnd ();
Lippi 4:c157810a12c5 48 // wait_ms(1000);
Lippi 4:c157810a12c5 49 // TurnUntilLine();
Lippi 3:b6754e794335 50 }
Lippi 4:c157810a12c5 51
Lippi 3:b6754e794335 52
Lippi 4:c157810a12c5 53
Lippi 4:c157810a12c5 54
Lippi 3:b6754e794335 55 }
Lippi 4:c157810a12c5 56