![](/media/cache/img/default_profile.jpg.50x50_q85.jpg)
TP_presa
Dependencies: SRF08 Servo mbed
Diff: main.cpp
- Revision:
- 8:ea8db9aacdfb
- Parent:
- 7:7d3c6326cbc3
- Child:
- 9:53a6a4e0db9f
diff -r 7d3c6326cbc3 -r ea8db9aacdfb main.cpp --- a/main.cpp Mon Jun 26 09:58:11 2017 +0000 +++ b/main.cpp Mon Jul 03 09:04:23 2017 +0000 @@ -23,6 +23,7 @@ void act() { action=bth.getc(); + bState = 0; switch(action) { case 'a': bth.printf("avancer\n\r"); @@ -56,14 +57,9 @@ bth.printf("demi tour left\n\r"); robot.demi_tour_gauche(100); break; - case not 'o': - bState = 0; case 'o': bState = !bState; - if (not bState) { - bth.printf("stop\n\r"); - robot.arreter(); - } + iState = 0; break; } action='0'; @@ -78,16 +74,15 @@ int visu; bth.baud(57600); bth.attach(&act); - + bState = 1; servo.period(0.02); while(1) { - bState = 1; if (bState) { switch (iState) { case 0: - if (srf08.read() <60 and srf08.read() >0 ) { + if (srf08.read() <40 and srf08.read() >0 ) { iState = 1; bth.printf("stop\n\r"); robot.arreter(); @@ -100,20 +95,23 @@ case 1 : servo.write(0.05); - wait (0.2); + wait (0.4); aMes[1] = srf08.read(); - servo.write(0.1); - wait (0.2); + servo.write(0.095); + wait (0.4); aMes[2]= srf08.read(); servo.write(0.08); - - if (aMes[1] <100 and aMes[1] >0) { + + bth.printf("capt 1 : %.2f capt 2 : %.2f",aMes[1], aMes[2]); + //if (aMes[1] <80 and aMes[1] >0) + if (aMes[2]>40) { action = 'g'; bth.printf("gauche\n\r"); robot.tourner_gauche(70); - } else if (aMes[2] <100 and aMes[2] >0) { + //} else if (aMes[2] <80 and aMes[2] >0) { + } else if (aMes[1]>40) { bth.printf("droite\n\r"); robot.tourner_droite(70); } else {