SmartWheels self-driving race car. Designed for NXP Cup. Uses FRDM-KL25Z, area-scan camera, and simple image processing to detect and navigate any NXP spec track.

Dependencies:   TSI USBDevice mbed-dev

Fork of SmartWheels by haofan Zheng

Motor.cpp

Committer:
Bobymicjohn
Date:
2017-02-02
Revision:
4:25e028102625
Child:
8:92f6baeea027

File content as of revision 4:25e028102625:

#include "Motor.h"
#include "mbed.h"
/*
DigitalOut DIR_L(PTA13);
DigitalOut DIR_R(PTC9);

PwmOut PWM_L(PTD0);
PwmOut PWM_R(PTD5);

Motor::Motor()
{
    
}
    
void Motor::initializeMotor()
{    
}

void Motor::setLeftSpeed(int speed)
{
    init();
    PWM_L.period_us(60);
    
    bool reverse = 0;
    
    if(speed < 0)
    {
        speed = -speed;
        reverse = 1;    
    }
    //Set Max Speed
    if(speed > 60)
        speed = 60;
        
    if(reverse)
        DIR_L = 1;
    else
        DIR_L = 0;

    PWM_L.pulsewidth_us(speed);
}

void Motor::setRightSpeed(int speed)
{
    init();
    PWM_R.period_us(60);
    
    bool reverse = 0;
    
    if(speed < 0)
    {
        speed = -speed;
        reverse = 1;    
    }
    //Set Max Speed
    if(speed > 60)
        speed = 60;
        
    if(reverse)
        DIR_R = 1;
    else
        DIR_R = 0;
    
    PWM_R.pulsewidth_us(speed);
}    

void Motor::setSpeeds(int leftSpeed, int rightSpeed)
{
    setLeftSpeed(leftSpeed);
    setRightSpeed(rightSpeed);    
}
*/