hallo

Dependencies:   mbed TB6612FNG

main.cpp

Committer:
kerim4040
Date:
2019-07-24
Revision:
1:1c01d379dd37
Parent:
0:d8e07dd54f68

File content as of revision 1:1c01d379dd37:

//Sample for TB6612FNG
//Gong Chen 2016.6.24s
#include "mbed.h"
#include "TB6612FNG.h"

//                    PWMA, AIN1, AIN2, PWMBm, BIN1, BIN2, STBY
TB6612FNG motorDriver(PC_6, PD_10, PD_8, PC_8, PG_2, PG_4, PD_12);

float fPwmPeriod;
float fPwmPulsewidth;

int main() {
    fPwmPeriod = 0.00002f;//50KHz
    fPwmPulsewidth = 1.0;//duty cycle 0.0~1.0 ->  0%~100%
    
    motorDriver.setPwmAperiod(fPwmPeriod);//set PWM Period
    motorDriver.setPwmBperiod(fPwmPeriod);
    
    motorDriver.setPwmApulsewidth(fPwmPulsewidth);//set PWM Puls Width
    motorDriver.setPwmBpulsewidth(fPwmPulsewidth);
    
    while(1)
    {
        motorDriver.motorA_ccw();//CounterClockWise
        wait(2);
        
        motorDriver.motorA_cw();//ClockWise
        wait(2);
                
        motorDriver.motorB_ccw();
        wait(2);
        
        motorDriver.motorB_cw();
        wait(2);
        

    }
    
}