small change

Dependencies:   mbed

Embed: (wiki syntax)

« Back to documentation index

Show/hide line numbers main.cpp Source File

main.cpp

00001 #include "mbed.h"
00002 
00003 PwmOut motor_pwm(D5);
00004 DigitalOut dir(D4);
00005 
00006 const int pwm_frequency     = 10000;    // PWM frequency
00007 bool direction              = false;     // Motor direction
00008 float duty_cycle            = 0;
00009 int main()
00010 {
00011     dir.write(direction);                   // Write motor direction
00012     motor_pwm.period(1/pwm_frequency);      // Motor PWM period
00013     motor_pwm.write(duty_cycle);            // Set motor speed
00014 
00015     while(true) {
00016         for(int i = 0; i<10; i++) {
00017             duty_cycle  = 0.1*i;
00018             motor_pwm.write(duty_cycle);
00019             wait(0.2);
00020         }
00021     duty_cycle = 0;
00022     motor_pwm.write(duty_cycle);
00023     }
00024 }
00025 
00026 
00027 // kleine text van anne