,,,,,,,,,,,,
Dependencies: CMPS03 SRF05 mbed pixy
Fork of 0000Non_stop_code_v1 by
fct.cpp@1:99f469d63b9a, 2017-06-10 (annotated)
- Committer:
- pirottealex
- Date:
- Sat Jun 10 07:20:21 2017 +0000
- Revision:
- 1:99f469d63b9a
- Parent:
- 0:a8cee96c9250
llllllllllllllllllllllllllll;
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
pirottealex | 0:a8cee96c9250 | 1 | #include "mbed.h" |
pirottealex | 0:a8cee96c9250 | 2 | #include "fct.h" |
pirottealex | 0:a8cee96c9250 | 3 | #include "SRF05.h" |
pirottealex | 0:a8cee96c9250 | 4 | |
pirottealex | 0:a8cee96c9250 | 5 | void vitmoteur(float VitG, float VitD) |
pirottealex | 0:a8cee96c9250 | 6 | { |
pirottealex | 0:a8cee96c9250 | 7 | if(VitG<0) { |
pirottealex | 0:a8cee96c9250 | 8 | VitG=-1*VitG; |
pirottealex | 0:a8cee96c9250 | 9 | cmdI2C=cmdI2C&0xfe; //passe le moteur gauche en marche arriere 00000001 |
pirottealex | 0:a8cee96c9250 | 10 | } else { |
pirottealex | 0:a8cee96c9250 | 11 | cmdI2C=cmdI2C|0x01; // marche avant 11110111 mot gauche |
pirottealex | 0:a8cee96c9250 | 12 | } |
pirottealex | 0:a8cee96c9250 | 13 | if(VitD<0) { |
pirottealex | 0:a8cee96c9250 | 14 | VitD=-1*VitD; |
pirottealex | 0:a8cee96c9250 | 15 | cmdI2C=cmdI2C&0xfd; //passe le moteur gauche en marche arriere 00000100 |
pirottealex | 0:a8cee96c9250 | 16 | } else { |
pirottealex | 0:a8cee96c9250 | 17 | cmdI2C=cmdI2C|0x02;//marche avant 11111011 mot droit |
pirottealex | 0:a8cee96c9250 | 18 | } |
pirottealex | 0:a8cee96c9250 | 19 | monI2C.write(ADR_PCF,&cmdI2C,1); |
pirottealex | 0:a8cee96c9250 | 20 | MotG.pulsewidth(((100-VitG)/100.0)*PERIOD); |
pirottealex | 0:a8cee96c9250 | 21 | MotD.pulsewidth(((100-VitD)/100.0)*PERIOD); |
pirottealex | 0:a8cee96c9250 | 22 | } |
pirottealex | 0:a8cee96c9250 | 23 | void lecture_blanc(void) |
pirottealex | 0:a8cee96c9250 | 24 | { |
pirottealex | 0:a8cee96c9250 | 25 | if(C1.read()>0.5) { |
pirottealex | 0:a8cee96c9250 | 26 | captL1=0; |
pirottealex | 0:a8cee96c9250 | 27 | } else { |
pirottealex | 0:a8cee96c9250 | 28 | captL1=1; |
pirottealex | 0:a8cee96c9250 | 29 | } |
pirottealex | 0:a8cee96c9250 | 30 | if(C3.read()>0.5) { |
pirottealex | 0:a8cee96c9250 | 31 | captL3=0; |
pirottealex | 0:a8cee96c9250 | 32 | } else { |
pirottealex | 0:a8cee96c9250 | 33 | captL3=1; |
pirottealex | 0:a8cee96c9250 | 34 | } |
pirottealex | 0:a8cee96c9250 | 35 | } |
pirottealex | 0:a8cee96c9250 | 36 | |
pirottealex | 0:a8cee96c9250 | 37 | void lecture_us(void) |
pirottealex | 0:a8cee96c9250 | 38 | { |
pirottealex | 0:a8cee96c9250 | 39 | us_arriere=us_arr.read(); |
pirottealex | 0:a8cee96c9250 | 40 | } |
pirottealex | 0:a8cee96c9250 | 41 | |
pirottealex | 0:a8cee96c9250 | 42 | void init(void) |
pirottealex | 0:a8cee96c9250 | 43 | { |
pirottealex | 0:a8cee96c9250 | 44 | bp.mode(PullUp); |
pirottealex | 0:a8cee96c9250 | 45 | MotG.period(PERIOD); |
pirottealex | 0:a8cee96c9250 | 46 | MotD.period(PERIOD); |
pirottealex | 0:a8cee96c9250 | 47 | vitmoteur(0,0); |
pirottealex | 0:a8cee96c9250 | 48 | } |
pirottealex | 0:a8cee96c9250 | 49 | |
pirottealex | 0:a8cee96c9250 | 50 | void lecture_boussole(void) |
pirottealex | 0:a8cee96c9250 | 51 | { |
pirottealex | 0:a8cee96c9250 | 52 | gBoussole=Boussole.readBearing() / 10.0; |
pirottealex | 0:a8cee96c9250 | 53 | } |