![](/media/cache/img/default_profile.jpg.50x50_q85.jpg)
coucou bob
fct.cpp@0:e9a025a937b4, 2018-12-17 (annotated)
- Committer:
- pirottealex
- Date:
- Mon Dec 17 16:50:36 2018 +0000
- Revision:
- 0:e9a025a937b4
robot play azur festival
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
pirottealex | 0:e9a025a937b4 | 1 | #include "mbed.h" |
pirottealex | 0:e9a025a937b4 | 2 | #include "fct.h" |
pirottealex | 0:e9a025a937b4 | 3 | |
pirottealex | 0:e9a025a937b4 | 4 | |
pirottealex | 0:e9a025a937b4 | 5 | void vitmoteur(float VitG, float VitD) |
pirottealex | 0:e9a025a937b4 | 6 | { |
pirottealex | 0:e9a025a937b4 | 7 | if(VitG<0) { |
pirottealex | 0:e9a025a937b4 | 8 | VitG=-1*VitG; |
pirottealex | 0:e9a025a937b4 | 9 | cmdI2C=cmdI2C&0xfe; //passe le moteur gauche en marche arriere 00000001 |
pirottealex | 0:e9a025a937b4 | 10 | } else { |
pirottealex | 0:e9a025a937b4 | 11 | cmdI2C=cmdI2C|0x01; // marche avant 11110111 mot gauche |
pirottealex | 0:e9a025a937b4 | 12 | } |
pirottealex | 0:e9a025a937b4 | 13 | if(VitD<0) { |
pirottealex | 0:e9a025a937b4 | 14 | VitD=-1*VitD; |
pirottealex | 0:e9a025a937b4 | 15 | cmdI2C=cmdI2C&0xfd; //passe le moteur gauche en marche arriere 00000100 |
pirottealex | 0:e9a025a937b4 | 16 | } else { |
pirottealex | 0:e9a025a937b4 | 17 | cmdI2C=cmdI2C|0x02;//marche avant 11111011 mot droit |
pirottealex | 0:e9a025a937b4 | 18 | } |
pirottealex | 0:e9a025a937b4 | 19 | monI2C.write(ADR_PCF,&cmdI2C,1); |
pirottealex | 0:e9a025a937b4 | 20 | MotG.pulsewidth(((100-VitG)/100.0)*PERIOD); |
pirottealex | 0:e9a025a937b4 | 21 | MotD.pulsewidth(((100-VitD)/100.0)*PERIOD); |
pirottealex | 0:e9a025a937b4 | 22 | } |
pirottealex | 0:e9a025a937b4 | 23 | |
pirottealex | 0:e9a025a937b4 | 24 | |
pirottealex | 0:e9a025a937b4 | 25 | void init(void) |
pirottealex | 0:e9a025a937b4 | 26 | { |
pirottealex | 0:e9a025a937b4 | 27 | |
pirottealex | 0:e9a025a937b4 | 28 | MotG.period(PERIOD); |
pirottealex | 0:e9a025a937b4 | 29 | MotD.period(PERIOD); |
pirottealex | 0:e9a025a937b4 | 30 | vitmoteur(0,0); |
pirottealex | 0:e9a025a937b4 | 31 | } |
pirottealex | 0:e9a025a937b4 | 32 | |
pirottealex | 0:e9a025a937b4 | 33 | |
pirottealex | 0:e9a025a937b4 | 34 |