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 ledr(PA_11); 00004 PwmOut ledy(PB_15); 00005 PwmOut ledb(PB_14); 00006 PwmOut ledg(PB_13); 00007 DigitalOut led(A0); 00008 00009 void initmotor(){ 00010 00011 ledr.period_us(256);//256*10'-6 00012 ledy.period_us(256);//256*10'-6 00013 ledb.period_us(256);//256*10'-6 00014 ledg.period_us(256);//256*10'-6 00015 00016 00017 ledr.pulsewidth_us(256); 00018 ledy.pulsewidth_us(256); 00019 ledb.pulsewidth_us(256); 00020 ledg.pulsewidth_us(256); } 00021 00022 int main() { 00023 int i; 00024 led=1; 00025 initmotor(); 00026 00027 while(1){ 00028 00029 for(i=0;i<256;i++){ 00030 ledr.pulsewidth_us(i); 00031 ledy.pulsewidth_us(256); 00032 ledb.pulsewidth_us(256); 00033 ledg.pulsewidth_us(i); 00034 00035 wait(0.0001); 00036 } 00037 for(i=255;i>0;i--){ 00038 ledr.pulsewidth_us(i); 00039 ledy.pulsewidth_us(256); 00040 ledb.pulsewidth_us(256); 00041 ledg.pulsewidth_us(i); 00042 wait(0.0001); 00043 00044 00045 for(i=255;i>0;i--){ 00046 ledr.pulsewidth_us(256); 00047 ledy.pulsewidth_us(i); 00048 ledb.pulsewidth_us(i); 00049 ledg.pulsewidth_us(256); 00050 00051 wait(0.0001); 00052 } 00053 for(i=0;i<255;i++){ 00054 ledr.pulsewidth_us(256); 00055 ledy.pulsewidth_us(i); 00056 ledb.pulsewidth_us(i); 00057 ledg.pulsewidth_us(256); 00058 wait(0.0001); 00059 00060 } 00061 } 00062 00063 } 00064 00065 }
Generated on Wed Jul 13 2022 14:24:31 by
1.7.2