Rob Toulson / Mbed 2 deprecated PE_04-05_PWMDCMotor

Dependencies:   mbed

Embed: (wiki syntax)

« Back to documentation index

Show/hide line numbers main.cpp Source File

main.cpp

00001 /*Program Example 4.5: PWM control to DC motor is repeatedly ramped
00002                                                                        */
00003 #include "mbed.h"
00004 PwmOut PWM1(p21);
00005 float i;
00006 int main()
00007 {
00008     PWM1.period(0.010);                  //set PWM period to 10 ms
00009     while(1) {
00010         for (i=0; i<1; i=i+0.01) {
00011             PWM1=i;                          // update PWM duty cycle
00012             wait(0.2);
00013         }
00014     }
00015 }