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.
Moteur.cpp
00001 #include "Moteur.h" 00002 00003 00004 #define PERIODE_PWM_MOTEUR 0.001 00005 00006 PwmOut mypwm_a(D6); 00007 PwmOut mypwm_b(D11); 00008 00009 DigitalOut in1(D7); 00010 DigitalOut in2(D8); 00011 DigitalOut in3(D9); 00012 DigitalOut in4(D10); 00013 00014 00015 00016 void moteur_init() 00017 { 00018 mypwm_a.period(PERIODE_PWM_MOTEUR); 00019 mypwm_b.period(PERIODE_PWM_MOTEUR); 00020 mypwm_a.pulsewidth(0); 00021 mypwm_b.pulsewidth(0); 00022 } 00023 00024 void moteur_a(float percent) 00025 { 00026 00027 if (percent>=0) { 00028 in1 = 1; 00029 in2 = 0; 00030 } else { 00031 in1 = 0; 00032 in2 = 1; 00033 percent = -1 * percent; 00034 } 00035 mypwm_a.pulsewidth((float)percent*(float)PERIODE_PWM_MOTEUR); 00036 } 00037 00038 void moteur_b(float percent) 00039 { 00040 00041 if (percent>=0) { 00042 in4 = 1; 00043 in3 = 0; 00044 } else { 00045 in4 = 0; 00046 in3 = 1; 00047 percent = -1 * percent; 00048 } 00049 00050 mypwm_b.pulsewidth((float)percent*(float)PERIODE_PWM_MOTEUR); 00051 }
Generated on Wed Jul 13 2022 05:21:05 by
1.7.2