kevin eccli / Mbed 2 deprecated Freescale_CupV4

Dependencies:   mbed

Embed: (wiki syntax)

« Back to documentation index

Show/hide line numbers Direction.cpp Source File

Direction.cpp

00001 #include "Direction.h"
00002 
00003 //INSTANCIATION DES INSTANCES GLOBALES
00004 PwmOut direction(DIR_PIN);
00005 
00006 void initDirection() {
00007     direction.period(DIR_PERIOD);
00008     setDirection(128);
00009 }
00010 
00011 /*en float : ~0.025 ->     roues braquées a gauche
00012              ~0.08 ->  roues braquées a droite
00013   en int : 0 ->    gauche
00014            256 ->  droite*/
00015 void setDirection(int dir) {
00016     direction.write(((((float)dir)/256)*0.055f + 0.025f));
00017 }
00018 
00019 
00020 void testDirection() {
00021     float vMoteur = 0.0;
00022     for(int i=0;i<256;i++)
00023     { 
00024         setDirection(i);
00025         xbee.printf("i = %d  ;   direction = %f\n",i,direction.read());
00026         wait(0.1f);
00027         vMoteur = (i-128.0f) / 128.0f;
00028         //setMoteurs(vMoteur,vMoteur);
00029         xbee.printf("vitesse moteurs : %f\n\n",vMoteur);
00030     }
00031 }