![](/media/cache/img/default_profile.jpg.50x50_q85.jpg)
coucou bob
Diff: fct.cpp
- Revision:
- 0:e9a025a937b4
diff -r 000000000000 -r e9a025a937b4 fct.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/fct.cpp Mon Dec 17 16:50:36 2018 +0000 @@ -0,0 +1,34 @@ +#include "mbed.h" +#include "fct.h" + + +void vitmoteur(float VitG, float VitD) +{ + if(VitG<0) { + VitG=-1*VitG; + cmdI2C=cmdI2C&0xfe; //passe le moteur gauche en marche arriere 00000001 + } else { + cmdI2C=cmdI2C|0x01; // marche avant 11110111 mot gauche + } + if(VitD<0) { + VitD=-1*VitD; + cmdI2C=cmdI2C&0xfd; //passe le moteur gauche en marche arriere 00000100 + } else { + cmdI2C=cmdI2C|0x02;//marche avant 11111011 mot droit + } + monI2C.write(ADR_PCF,&cmdI2C,1); + MotG.pulsewidth(((100-VitG)/100.0)*PERIOD); + MotD.pulsewidth(((100-VitD)/100.0)*PERIOD); +} + + +void init(void) +{ + + MotG.period(PERIOD); + MotD.period(PERIOD); + vitmoteur(0,0); +} + + + \ No newline at end of file