![](/media/cache/img/default_profile.jpg.50x50_q85.jpg)
limit switch example
Diff: main.cpp
- Revision:
- 2:fd4ab491b054
- Parent:
- 1:fe798c459fdb
diff -r fe798c459fdb -r fd4ab491b054 main.cpp --- a/main.cpp Tue Jul 17 00:29:53 2018 +0000 +++ b/main.cpp Tue Jul 17 00:51:06 2018 +0000 @@ -1,15 +1,17 @@ #include "mbed.h" -PwmOut mypwm(PA_10); +PwmOut mypwm0(PB_0); +PwmOut mypwm1(PB_1); InterruptIn button(PB_3); DigitalOut myled(LED1); void stop(); int main() { - button.rise(&stop); - mypwm.period_ms(10); - mypwm.pulsewidth_ms(9); - + // button.rise(&stop); + mypwm0.period_ms(10); + mypwm0.pulsewidth_ms(8); + mypwm1.period_ms(10); + mypwm1.pulsewidth_ms(0); while(1) { myled = !myled; wait(1); @@ -19,7 +21,8 @@ void stop() { wait(0.01); if(button.read() == 1){ - mypwm.write(0); + mypwm0.write(0); + mypwm1.write(0); } }