final project update
Dependencies: mbed
Fork of DISCO_SMT32L4_pwm_PB3 by
Diff: main.cpp
- Revision:
- 4:9d26d117fa69
- Parent:
- 3:9aa9bfe031bb
- Child:
- 5:620125c08317
diff -r 9aa9bfe031bb -r 9d26d117fa69 main.cpp --- a/main.cpp Mon Mar 19 20:01:16 2018 +0000 +++ b/main.cpp Tue Apr 17 21:04:18 2018 +0000 @@ -1,8 +1,9 @@ #include "mbed.h" PwmOut mypwm(PWM_OUT); +PwmOut ndpwm(LED1); +PwmOut rdpwm(JOYSTICK_LEFT); -DigitalOut myled(LED1); #define UP 1 #define DOWN 2 @@ -16,16 +17,26 @@ mypwm.period_ms(10); mypwm.pulsewidth_ms(1); + ndpwm.period_ms(10); + ndpwm.pulsewidth_ms(1); + + rdpwm.period_ms(10); + rdpwm.pulsewidth_ms(1); + printf("pwm set to %.2f %%\n", mypwm.read() * 100); + printf("2nd pwm set to %.2f %%\n", ndpwm.read() * 100); + printf("3rd pwm set to %.2f %%\n", rdpwm.read() * 100); count_dir = UP; while(1) { - myled = !myled; + for(i = 0; i < 10; i++ ) { wait(0.1); if(count_dir == UP) { + rdpwm = rdpwm + 0.5; + ndpwm = ndpwm + 0.25; mypwm = mypwm + 0.01; if(mypwm == 1.00) // if hit one, start counting down { @@ -34,6 +45,8 @@ } else if(count_dir == DOWN) { + rdpwm = rdpwm - 0.5; + ndpwm = ndpwm - 0.25; mypwm = mypwm - 0.01; if(mypwm == 0.0) // if hit zero, start counting up { @@ -43,5 +56,7 @@ } printf("pwm set to %.2f %%\n\r", mypwm.read() * 100); + printf("2nd pwm set to %.2f %%\n\r", ndpwm.read() * 100); + printf("3rd pwm set to %.2f %%\n\r", rdpwm.read() * 100); } }