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
main.cpp
- Committer:
- wiz0rk
- Date:
- 2022-06-10
- Revision:
- 1:5d958973e71a
- Parent:
- 0:c2fc9085cc53
File content as of revision 1:5d958973e71a:
#include "mbed.h" //CNY70 DigitalIn CNY_1 (PA_12); DigitalIn CNY_2 (PB_2); DigitalIn CNY_3 (PC_6); DigitalIn CNY_4 (PB_12); // Moteur 1 DigitalOut INA1(PA_10); DigitalOut INB1(PB_3); DigitalOut EN1(PB_10); PwmOut PWM1(PB_14); // Moteur 2 DigitalOut INA2(PA_8); DigitalOut INB2(PA_9); DigitalOut EN2(PA_6); PwmOut PWM2(PB_13); DigitalIn Jack (PB_15, PullUp); void init_moteur() ; #define vitesse 0.2 bool flag=0; void init_moteur() { EN1=1; INA1 = 0; INB1 = 0; PWM1.period(0.00005); // 20 kHz (valid 0 - 20 kHz) PWM1.write(0); EN2=1; INA2 = 0; INB2 = 0; PWM2.period(0.00005); // 20 kHz (valid 0 - 20 kHz) PWM2.write(0); } int main() { init_moteur(); while (true) { if (Jack==1){ if (CNY_1==1 and CNY_2==1 and CNY_3==1 and CNY_4==1 and flag==0){ INA1 = 1; INB1 = 0; INA2 = 0; INB2 = 1; PWM1.write(vitesse); PWM2.write(vitesse); flag=1; wait (0.3); PWM1.write(0); PWM2.write(0); } if (CNY_1==0 and CNY_2==0 and CNY_3==0 and CNY_4==0 and flag==0){ INA1 = 0; INB1 = 1; INA2 = 1; INB2 = 0; PWM1.write(vitesse); PWM2.write(vitesse+0.005); } } } }