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.
Diff: main.cpp
- Revision:
- 0:d9f7857bdaf1
diff -r 000000000000 -r d9f7857bdaf1 main.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/main.cpp Sun Aug 28 17:04:24 2016 +0000 @@ -0,0 +1,65 @@ +#include "mbed.h" + +PwmOut ledr(PA_11); +PwmOut ledy(PB_15); +PwmOut ledb(PB_14); +PwmOut ledg(PB_13); +DigitalOut led(A0); + +void initmotor(){ + + ledr.period_us(256);//256*10'-6 + ledy.period_us(256);//256*10'-6 + ledb.period_us(256);//256*10'-6 + ledg.period_us(256);//256*10'-6 + + + ledr.pulsewidth_us(256); + ledy.pulsewidth_us(256); + ledb.pulsewidth_us(256); + ledg.pulsewidth_us(256); } + +int main() { + int i; + led=1; + initmotor(); + + while(1){ + + for(i=0;i<256;i++){ + ledr.pulsewidth_us(i); + ledy.pulsewidth_us(256); + ledb.pulsewidth_us(256); + ledg.pulsewidth_us(i); + + wait(0.0001); + } + for(i=255;i>0;i--){ + ledr.pulsewidth_us(i); + ledy.pulsewidth_us(256); + ledb.pulsewidth_us(256); + ledg.pulsewidth_us(i); + wait(0.0001); + + + for(i=255;i>0;i--){ + ledr.pulsewidth_us(256); + ledy.pulsewidth_us(i); + ledb.pulsewidth_us(i); + ledg.pulsewidth_us(256); + + wait(0.0001); + } + for(i=0;i<255;i++){ + ledr.pulsewidth_us(256); + ledy.pulsewidth_us(i); + ledb.pulsewidth_us(i); + ledg.pulsewidth_us(256); + wait(0.0001); + + } + } + + } + +} \ No newline at end of file