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 00003 PwmOut ENA(D11); 00004 DigitalOut IN1(D3); 00005 DigitalOut IN2(D4); 00006 PwmOut ENB(D12); 00007 DigitalOut IN3(D5); 00008 DigitalOut IN4(D6); 00009 AnalogIn dial(A0); 00010 AnalogIn distance(A1); 00011 00012 int main() { 00013 ENA.period(0.01); 00014 ENB.period(0.01); 00015 ENA=0; 00016 ENB=0; 00017 IN1=1; 00018 IN2=0; 00019 IN3=1; 00020 IN4=0; 00021 00022 00023 while(1){ 00024 float pwm = dial.read(); 00025 float dist=distance.read(); 00026 printf("%f,%f\n",pwm,dist); 00027 if(dist<0.5){ 00028 IN1=1; 00029 IN2=0; 00030 IN3=1; 00031 IN4=0; 00032 } else { 00033 IN1=1; 00034 IN2=0; 00035 IN3=0; 00036 IN4=1; 00037 } 00038 ENA = pwm; 00039 ENB = pwm; 00040 } 00041 }
Generated on Mon Aug 1 2022 21:13:08 by
1.7.2