Yifan Weng
/
Buggyproject
Convert the pwm signal generated by reciever into a signal used by H-bridge
Revision 0:c66e5ca3bad6, committed 2019-05-06
- Comitter:
- fy17y2w
- Date:
- Mon May 06 21:24:22 2019 +0000
- Commit message:
- N/A
Changed in this revision
diff -r 000000000000 -r c66e5ca3bad6 PwmIn.lib --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/PwmIn.lib Mon May 06 21:24:22 2019 +0000 @@ -0,0 +1,1 @@ +http://mbed.org/users/simon/code/PwmIn/#6d68eb9b6bbb
diff -r 000000000000 -r c66e5ca3bad6 main.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/main.cpp Mon May 06 21:24:22 2019 +0000 @@ -0,0 +1,46 @@ +#include "mbed.h" +#include "PwmIn.h" + + +Timer t; +PwmOut white_up(PC_8),white_down(PC_9),gray_up(PC_6),gray_down(PB_8); +PwmIn lin(A0),rin(A1); +int main() +{ + white_up.period_ms(2.5); + white_down.period_ms(2.5); + gray_up.period_ms(2.5); + gray_down.period_ms(2.5); + while(1){ + if(lin.dutycycle()<0.59 ){ + gray_down.write(-(lin.dutycycle()-0.59)*4.34); + wait_ms(10); + } + else if(lin.dutycycle()>0.61){ + white_down.write((lin.dutycycle()-0.61)*4.54 ); + wait_ms(10); + } + else{ + white_down.write(0); + gray_down.write(0); + wait_ms(10); + } + if(rin.dutycycle()< 0.59){ + gray_up.write(-(rin.dutycycle()-0.59)*4.34 ); + wait_ms(10); + } + else if(rin.dutycycle()>0.61){ + white_up.write((rin.dutycycle()-0.61)*4.34 ); + wait_ms(10); + } + else{ + white_up.write(0); + gray_up.write(0); + wait_ms(10); + } + } + + + + +}
diff -r 000000000000 -r c66e5ca3bad6 mbed.bld --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/mbed.bld Mon May 06 21:24:22 2019 +0000 @@ -0,0 +1,1 @@ +https://os.mbed.com/users/mbed_official/code/mbed/builds/65be27845400 \ No newline at end of file