eLab Team / Mbed OS DcMotorTest

main_old.txt

Committer:
elab
Date:
2021-01-28
Revision:
0:708b17957be1

File content as of revision 0:708b17957be1:

#include "mbed.h"


PwmOut DCMotor(D6);
PwmOut ServoClockWise(D5);
PwmOut ServoCounterCW(D3);

DigitalOut DCMotor_IN1(D7);
DigitalOut DCMotor_IN2(D8);
DigitalOut ServoEnable(D4);



int main()
{
    DCMotor.period_ms(20);    // shoul be 20 ms (490 Hz) and 10 ms for the servo (980 Hz)
    ServoClockWise.period_ms(10);
    ServoCounterCW.period_ms(10);
    ServoEnable=1;

    DCMotor_IN1=0;
    DCMotor_IN2=1;
    DCMotor.pulsewidth_us(1500);
//    wait(5);
//    DCMotor.pulsewidth_ms(0);
   
    
    
    while(0){

        DCMotor_IN1=0;
        DCMotor_IN2=1;
        DCMotor.pulsewidth_ms(2);
        ServoClockWise.pulsewidth_us(0);
        ServoCounterCW.pulsewidth_us(100);
        wait_ms(1000);
        ServoCounterCW.pulsewidth_us(19000);
        wait_ms(1000);

        DCMotor_IN1=1;
        DCMotor_IN2=0;
        DCMotor.pulsewidth_ms(10);
        ServoCounterCW.pulsewidth_us(0);
        ServoClockWise.pulsewidth_us(100);
        wait_ms(1000);
        ServoClockWise.pulsewidth_us(19000);
        wait_ms(1000);
        
    }
}