dgfn

Dependencies:   mbed tsi_sensor

Committer:
benbrou06
Date:
Sat Dec 14 09:09:30 2019 +0000
Revision:
0:84a89cfeff98
yuez

Who changed what in which revision?

UserRevisionLine numberNew contents of line
benbrou06 0:84a89cfeff98 1 //#define Test_Capteur
benbrou06 0:84a89cfeff98 2 #ifdef Test_Capteur
benbrou06 0:84a89cfeff98 3
benbrou06 0:84a89cfeff98 4 #include <stdio.h>
benbrou06 0:84a89cfeff98 5 #include "mbed.h"
benbrou06 0:84a89cfeff98 6
benbrou06 0:84a89cfeff98 7
benbrou06 0:84a89cfeff98 8 //Entrées analogiques des capteurs
benbrou06 0:84a89cfeff98 9 AnalogIn Captd1(PTB1); //capteur droite 1
benbrou06 0:84a89cfeff98 10 AnalogIn Captd2(PTB2); //capteur droite 2
benbrou06 0:84a89cfeff98 11 AnalogIn Captg1(PTC2); //capteur gauche 1
benbrou06 0:84a89cfeff98 12 AnalogIn Captg2(PTB3); //capteur gauche 2
benbrou06 0:84a89cfeff98 13
benbrou06 0:84a89cfeff98 14
benbrou06 0:84a89cfeff98 15 PwmOut Motg(PTC8); //Déclaration PWM des moteurs
benbrou06 0:84a89cfeff98 16 PwmOut Motd(PTA13);
benbrou06 0:84a89cfeff98 17
benbrou06 0:84a89cfeff98 18
benbrou06 0:84a89cfeff98 19
benbrou06 0:84a89cfeff98 20 int main()
benbrou06 0:84a89cfeff98 21 {
benbrou06 0:84a89cfeff98 22 float CD1,CG1,CD2,CG2;
benbrou06 0:84a89cfeff98 23 Motg.period_us(100);
benbrou06 0:84a89cfeff98 24 Motd.period_us(100);
benbrou06 0:84a89cfeff98 25 float Vmg=100,Vmd=100; //Les 2 moteurs
benbrou06 0:84a89cfeff98 26 Motg.pulsewidth_us(Vmg); //Vitesses des 2 moteurs
benbrou06 0:84a89cfeff98 27 Motd.pulsewidth_us(Vmd);
benbrou06 0:84a89cfeff98 28 printf("Debut pgrm\n\r");
benbrou06 0:84a89cfeff98 29
benbrou06 0:84a89cfeff98 30 while(1) {
benbrou06 0:84a89cfeff98 31 CD1 = Captd1;
benbrou06 0:84a89cfeff98 32 CD2 = Captd2;
benbrou06 0:84a89cfeff98 33 CG1 = Captg1;
benbrou06 0:84a89cfeff98 34 CG2 = Captg2;
benbrou06 0:84a89cfeff98 35 printf(" CD1 = %.3f ",CD1);
benbrou06 0:84a89cfeff98 36 printf(" CD2 = %.3f",CD2);
benbrou06 0:84a89cfeff98 37 printf(" CG1 = %.3f",CG1);
benbrou06 0:84a89cfeff98 38 printf(" CG2 = %.3f\n\r",CG2);
benbrou06 0:84a89cfeff98 39
benbrou06 0:84a89cfeff98 40
benbrou06 0:84a89cfeff98 41 /*
benbrou06 0:84a89cfeff98 42
benbrou06 0:84a89cfeff98 43 if (Captg1 < 0.5) {
benbrou06 0:84a89cfeff98 44 printf("Tourne a gauche\n\r");
benbrou06 0:84a89cfeff98 45 }
benbrou06 0:84a89cfeff98 46
benbrou06 0:84a89cfeff98 47 else if (Captd1 < 0.5) {
benbrou06 0:84a89cfeff98 48 printf("Tourne a droite\n\r");
benbrou06 0:84a89cfeff98 49 }
benbrou06 0:84a89cfeff98 50
benbrou06 0:84a89cfeff98 51 else if (Captg2 < 0.5) {
benbrou06 0:84a89cfeff98 52 printf("Tourne a gauche 90 deg\n\r");
benbrou06 0:84a89cfeff98 53 }
benbrou06 0:84a89cfeff98 54
benbrou06 0:84a89cfeff98 55 else if (Captd2 < 0.5) {
benbrou06 0:84a89cfeff98 56 printf("Tourne a droite 90 deg\n\r");
benbrou06 0:84a89cfeff98 57 }*/
benbrou06 0:84a89cfeff98 58
benbrou06 0:84a89cfeff98 59 }
benbrou06 0:84a89cfeff98 60 }
benbrou06 0:84a89cfeff98 61 #endif