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 "Motor.h" 00003 00004 //DigitalOut led(LED1); 00005 DigitalIn sw1(p5); 00006 DigitalIn sw2(p6); 00007 BusOut led(LED1,LED2,LED3,LED4); 00008 Motor m(p21, p11, p12); // pwm, fwd, rev 00009 00010 int main() { 00011 led = 0; 00012 m.speed(0); 00013 int count = 3; 00014 float speed = 0; 00015 while(1) { 00016 00017 if(sw1 == 0 && count < 5) 00018 { 00019 count ++; 00020 speed +=0.5; 00021 m.speed(speed); 00022 if(count == 3) 00023 led =0; 00024 else if (count == 1) 00025 led = 0x1; 00026 else if (count == 2) 00027 led = 0x2; 00028 else if (count == 4) 00029 led = 0x4; 00030 else if (count == 5) 00031 led = 0x8; 00032 wait(1); 00033 00034 } 00035 00036 else if(sw2 == 0 && count>0 ) 00037 { 00038 count --; 00039 speed -=0.5; 00040 m.speed(speed); 00041 if(count == 3) 00042 led =0; 00043 else if (count == 1) 00044 led = 0x1; 00045 else if (count == 2) 00046 led = 0x2; 00047 else if (count == 4) 00048 led = 0x4; 00049 else if (count == 5) 00050 led = 0x8; 00051 00052 wait(1); 00053 } 00054 } 00055 }
Generated on Wed Jul 20 2022 02:09:55 by
1.7.2