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.
Dependencies: mbed
Direction.cpp@0:1b0dce2e60ba, 2014-12-01 (annotated)
- Committer:
- singularity
- Date:
- Mon Dec 01 21:24:13 2014 +0000
- Revision:
- 0:1b0dce2e60ba
Dernier commit
Who changed what in which revision?
| User | Revision | Line number | New contents of line |
|---|---|---|---|
| singularity | 0:1b0dce2e60ba | 1 | #include "Direction.h" |
| singularity | 0:1b0dce2e60ba | 2 | |
| singularity | 0:1b0dce2e60ba | 3 | //INSTANCIATION DES INSTANCES GLOBALES |
| singularity | 0:1b0dce2e60ba | 4 | PwmOut direction(DIR_PIN); |
| singularity | 0:1b0dce2e60ba | 5 | |
| singularity | 0:1b0dce2e60ba | 6 | void initDirection() { |
| singularity | 0:1b0dce2e60ba | 7 | direction.period(DIR_PERIOD); |
| singularity | 0:1b0dce2e60ba | 8 | setDirection(128); |
| singularity | 0:1b0dce2e60ba | 9 | } |
| singularity | 0:1b0dce2e60ba | 10 | |
| singularity | 0:1b0dce2e60ba | 11 | /*en float : ~0.025 -> roues braquées a gauche |
| singularity | 0:1b0dce2e60ba | 12 | ~0.08 -> roues braquées a droite |
| singularity | 0:1b0dce2e60ba | 13 | en int : 0 -> gauche |
| singularity | 0:1b0dce2e60ba | 14 | 256 -> droite*/ |
| singularity | 0:1b0dce2e60ba | 15 | void setDirection(int dir) { |
| singularity | 0:1b0dce2e60ba | 16 | direction.write(((((float)dir)/256)*0.055f + 0.025f)); |
| singularity | 0:1b0dce2e60ba | 17 | } |
| singularity | 0:1b0dce2e60ba | 18 | |
| singularity | 0:1b0dce2e60ba | 19 | |
| singularity | 0:1b0dce2e60ba | 20 | void testDirection() { |
| singularity | 0:1b0dce2e60ba | 21 | float vMoteur = 0.0; |
| singularity | 0:1b0dce2e60ba | 22 | for(int i=0;i<256;i++) |
| singularity | 0:1b0dce2e60ba | 23 | { |
| singularity | 0:1b0dce2e60ba | 24 | setDirection(i); |
| singularity | 0:1b0dce2e60ba | 25 | xbee.printf("i = %d ; direction = %f\n",i,direction.read()); |
| singularity | 0:1b0dce2e60ba | 26 | wait(0.1f); |
| singularity | 0:1b0dce2e60ba | 27 | vMoteur = (i-128.0f) / 128.0f; |
| singularity | 0:1b0dce2e60ba | 28 | //setMoteurs(vMoteur,vMoteur); |
| singularity | 0:1b0dce2e60ba | 29 | xbee.printf("vitesse moteurs : %f\n\n",vMoteur); |
| singularity | 0:1b0dce2e60ba | 30 | } |
| singularity | 0:1b0dce2e60ba | 31 | } |