dgfn

Dependencies:   mbed tsi_sensor

main.cpp

Committer:
benbrou06
Date:
2019-12-14
Revision:
0:84a89cfeff98

File content as of revision 0:84a89cfeff98:

//#define Test_Capteur
#ifdef Test_Capteur

#include <stdio.h>
#include "mbed.h"


//Entrées analogiques des capteurs
AnalogIn Captd1(PTB1); //capteur droite 1
AnalogIn Captd2(PTB2); //capteur droite 2
AnalogIn Captg1(PTC2); //capteur gauche 1
AnalogIn Captg2(PTB3); //capteur gauche 2


PwmOut Motg(PTC8); //Déclaration PWM des moteurs
PwmOut Motd(PTA13);



int main()
{
    float CD1,CG1,CD2,CG2;
    Motg.period_us(100);
    Motd.period_us(100); 
    float Vmg=100,Vmd=100; //Les 2 moteurs
    Motg.pulsewidth_us(Vmg); //Vitesses des 2 moteurs
    Motd.pulsewidth_us(Vmd);
    printf("Debut pgrm\n\r");

    while(1) {
        CD1 = Captd1;
        CD2 = Captd2;
        CG1 = Captg1;
        CG2 = Captg2;
        printf("  CD1 = %.3f ",CD1);
        printf("  CD2 = %.3f",CD2);
        printf("  CG1 = %.3f",CG1);
        printf("  CG2 = %.3f\n\r",CG2);
        
        
   /*     
        
        if (Captg1 < 0.5) {
            printf("Tourne a gauche\n\r");
        }

        else if (Captd1 < 0.5) {
            printf("Tourne a droite\n\r");
        }

        else if (Captg2 < 0.5) {
            printf("Tourne a gauche 90 deg\n\r");
        }

        else if (Captd2 < 0.5) {
            printf("Tourne a droite 90 deg\n\r");
        }*/

    }
}
#endif