Akshay Kulkarni
/
frdm_dutycycle
This code explains the duty cycle changing process by which we can change the speed of the motor
Diff: main.cpp
- Revision:
- 0:82a1db9f5a98
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/main.cpp Fri May 06 23:46:33 2016 +0000 @@ -0,0 +1,32 @@ +#include "mbed.h" + +DigitalOut vcc(PTC16); +int i; + + +int main() +{ + +printf("Press 1 for full duty cycle\r\n",i); +printf("Press 2 for 75% duty cycle\r\n",i); +printf("Press 3 for 50% cycle\r\n",i); +printf("Press 4 for 25% cycle\r\n",i); +scanf("%d\n",&i); +printf("i= %d\n",i); + +while(i==1){vcc=!vcc;} +while(i==2){vcc=!vcc; +wait(0.75); +vcc=0; +wait(0.25);} + +while(i==3){vcc=!vcc; +wait(0.5); +vcc=0; +wait(0.5);} + +while(i==4){vcc=!vcc; +wait(0.25); +vcc=0; +wait(0.75);} +}