Motor test

Dependencies:   mbed

Fork of motor_test by Björn Nijhuis

main.cpp

Committer:
bjornnijhuis
Date:
2015-09-23
Revision:
0:c931a374f94f

File content as of revision 0:c931a374f94f:

#include "mbed.h"

PwmOut motor_pwm(D5);
DigitalOut dir(D4);
DigitalOut led_r (LED_RED);   

//const int pwm_frequency     = 10000;    // PWM frequency
const float duty_cycle      = 0.5;      // Duty cycle (half speed)
bool direction              = true;     // Motor direction


int main()
{    
led_r.write(false);

while(true){
dir.write(direction);                   // Write motor direction
//motor_pwm.period(1/pwm_frequency);      // Motor PWM period
motor_pwm.write(duty_cycle);            // Set motor speed

}}