Adaptation K22F

Dependencies:   mbed

Committer:
singularity
Date:
Tue Dec 16 15:52:17 2014 +0000
Revision:
0:6004a7230f87
Creation k22F

Who changed what in which revision?

UserRevisionLine numberNew contents of line
singularity 0:6004a7230f87 1 #include "Direction.h"
singularity 0:6004a7230f87 2
singularity 0:6004a7230f87 3 //INSTANCIATION DES INSTANCES GLOBALES
singularity 0:6004a7230f87 4 PwmOut direction(DIR_PIN);
singularity 0:6004a7230f87 5
singularity 0:6004a7230f87 6 void initDirection() {
singularity 0:6004a7230f87 7 direction.period(DIR_PERIOD);
singularity 0:6004a7230f87 8 setDirection(128);
singularity 0:6004a7230f87 9 }
singularity 0:6004a7230f87 10
singularity 0:6004a7230f87 11 /*en float : ~0.025 -> roues braquées a gauche
singularity 0:6004a7230f87 12 ~0.08 -> roues braquées a droite
singularity 0:6004a7230f87 13 en int : 0 -> gauche
singularity 0:6004a7230f87 14 256 -> droite*/
singularity 0:6004a7230f87 15 void setDirection(int dir) {
singularity 0:6004a7230f87 16 direction.write(((((float)dir)/256)*0.055f + 0.025f));
singularity 0:6004a7230f87 17 }
singularity 0:6004a7230f87 18
singularity 0:6004a7230f87 19
singularity 0:6004a7230f87 20 void testDirection() {
singularity 0:6004a7230f87 21 float vMoteur = 0.0;
singularity 0:6004a7230f87 22 for(int i=0;i<256;i++)
singularity 0:6004a7230f87 23 {
singularity 0:6004a7230f87 24 setDirection(i);
singularity 0:6004a7230f87 25 xbee.printf("i = %d ; direction = %f\n",i,direction.read());
singularity 0:6004a7230f87 26 wait(0.1f);
singularity 0:6004a7230f87 27 vMoteur = (i-128.0f) / 128.0f;
singularity 0:6004a7230f87 28 //setMoteurs(vMoteur,vMoteur);
singularity 0:6004a7230f87 29 xbee.printf("vitesse moteurs : %f\n\n",vMoteur);
singularity 0:6004a7230f87 30 }
singularity 0:6004a7230f87 31 }