Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
Direction.cpp
- Committer:
- singularity
- Date:
- 2014-12-16
- Revision:
- 0:6004a7230f87
File content as of revision 0:6004a7230f87:
#include "Direction.h"
//INSTANCIATION DES INSTANCES GLOBALES
PwmOut direction(DIR_PIN);
void initDirection() {
direction.period(DIR_PERIOD);
setDirection(128);
}
/*en float : ~0.025 -> roues braquées a gauche
~0.08 -> roues braquées a droite
en int : 0 -> gauche
256 -> droite*/
void setDirection(int dir) {
direction.write(((((float)dir)/256)*0.055f + 0.025f));
}
void testDirection() {
float vMoteur = 0.0;
for(int i=0;i<256;i++)
{
setDirection(i);
xbee.printf("i = %d ; direction = %f\n",i,direction.read());
wait(0.1f);
vMoteur = (i-128.0f) / 128.0f;
//setMoteurs(vMoteur,vMoteur);
xbee.printf("vitesse moteurs : %f\n\n",vMoteur);
}
}