SEARCH
TOOLBOX
LANGUAGES
modified on 17 September 2014 at 19:06 ••• 11,443 views

04-05 PWMDCMotor

From Manuals

(Difference between revisions)
Jump to: navigation, search
Support (Talk | contribs)
(Created page with 'The example program uses a PWM output to control a servo motor. The servo motor is a HiTEC HS0422 /*Program Example 4.5: PWM control to DC motor is repeatedly ramped …')
Newer edit →

Revision as of 15:08, 14 August 2014

The example program uses a PWM output to control a servo motor. The servo motor is a HiTEC HS0422

/*Program Example 4.5: PWM control to DC motor is repeatedly ramped
                                                                      */
#include "mbed.h"
PwmOut motor(PWM1);
float i;

int main()
{
    motor.period(0.010);                  // set PWM period to 10 ms
    while(1) {
        for (i=0; i<1; i=i+0.01f) {
            motor=i;                      // update PWM duty cycle
            wait(0.2);
        }
    }
}



BAM210
Schematic for example 04-05