![](/media/cache/img/default_profile.jpg.50x50_q85.jpg)
oki
Fork of ProjetInfo2_Multi by
Diff: coffre.cpp
- Revision:
- 2:ae058dfdebac
- Parent:
- 0:5755bf39c144
- Child:
- 3:98f5de1dd010
- Child:
- 4:23e955d622f9
--- a/coffre.cpp Tue May 22 11:51:24 2018 +0000 +++ b/coffre.cpp Fri Jun 01 11:36:44 2018 +0000 @@ -1,21 +1,10 @@ #include"mbed.h" - -PwmOut servo (p21); BusIn digicode(p5,p6,p7,p8,p9,p10,p11,p12,p13,p14,p15,p16); - - -void fermer() -{ - servo.pulsewidth(0.194); -} - -void ouvrir() -{ - - servo.pulsewidth(0.178); -} +DigitalOut s(p17); +Timer t; +Timer t11; int lireval(){ int val; @@ -56,4 +45,49 @@ val=3; } return val; +} + +void servo() +{ + int c=0; + t.start(); + t11.start(); + { + while(c<1) + { + if (t11.read()>8) + { + t11.reset(); + c++; + } + if (t11.read()<4) + { + if(t.read()>0.02) + { t.reset();} + if (t.read()<0.0193) + { + s.write(1); + } + else + { + s.write(0); + } + } + else + { + if(t.read()>0.02) + { t.reset();} + if (t.read()< 0.0175) + { + s.write(1); + } + else + { + s.write(0); + } + } + + + } + } } \ No newline at end of file