ultra

Dependencies:   SRF05 mbed pixy

Embed: (wiki syntax)

« Back to documentation index

Show/hide line numbers fct.cpp Source File

fct.cpp

00001 #include "mbed.h"
00002 #include "fct.h"
00003 
00004 void Vitmoteur(float VitG, float VitD)
00005 {
00006     if(VitG<0) {
00007         VitG=-1*VitG;
00008         cmdI2C=cmdI2C&0xfe; //passe le moteur gauche en marche arriere 00000001
00009     } else {
00010         cmdI2C=cmdI2C|0x01; // marche avant 11110111 mot gauche
00011     }
00012     if(VitD<0) {
00013         VitD=-1*VitD;
00014         cmdI2C=cmdI2C&0xfd; //passe le moteur gauche en marche arriere 00000100
00015     } else {
00016         cmdI2C=cmdI2C|0x02;//marche avant 11111011 mot droit
00017     }
00018     monI2C.write(ADR_PCF,&cmdI2C,1);
00019     MotG.pulsewidth(((100-VitG)/100.0)*PERIOD);
00020     MotD.pulsewidth(((100-VitD)/100.0)*PERIOD);
00021 }
00022 void init(void)
00023 {
00024     if(C1.read()>0.5) {
00025         captL1=0;
00026     } else {
00027         captL1=1;
00028     }
00029     if(C3.read()>0.5) {
00030         captL3=0;
00031     } else {
00032         captL3=1;
00033     }
00034     
00035     
00036 
00037 }