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.
main.cpp
00001 #include "mbed.h" 00002 #include "CMPS03.h" 00003 00004 #define PERIOD 0.0001 00005 00006 CMPS03 boussole(p9,p10,CMPS03_DEFAULT_I2C_ADDRESS); 00007 00008 BusOut leds(LED1,LED2,LED3,LED4); 00009 00010 PwmOut MG(p21); //vitesse moteur gauche 00011 PwmOut MD(p24); //vitesse moteur droit 00012 DigitalOut sensMG(p23); // sens moteur gauche 00013 DigitalOut sensMD(p26); // sens moteur droit 00014 00015 float vitesse(float vit) 00016 { 00017 if(vit<0) vit=0; 00018 if(vit>60) vit=60; 00019 return ((vit/100.0)*PERIOD); 00020 } 00021 00022 00023 00024 int main() 00025 { 00026 00027 sensMG.write(1); 00028 sensMD.write(1); 00029 MG.period(PERIOD); 00030 MD.period(PERIOD); 00031 MG.pulsewidth(vitesse(0)); 00032 MD.pulsewidth(vitesse(0)); 00033 00034 while(1) { 00035 00036 printf("CAP=%.1f \n\r",boussole.readBearing()/10.0); 00037 wait(0.1); 00038 } 00039 00040 }
Generated on Mon Jul 25 2022 11:16:59 by
1.7.2