Create a motor object, to control a motor using L293DNE and FDRM-KL46z.

Dependencies:   mbed

Motor.cpp

Committer:
Dogcatfee
Date:
2017-10-25
Revision:
3:41acca236570
Parent:
2:538f0e257365

File content as of revision 3:41acca236570:

#include "mbed.h"
#include "Motor.h"

Motor::Motor(PinName Positive, PinName Negative): _positive(Positive), _negative(Negative){
     _positive.period(0.03f);      // 4 second period
     _positive.write(0.25f); 
     _negative.period(0.03f);      // 4 second period
    _negative.write(0.25f); 
     
}   
     /* Input 1 or 2 or LEFT and RIGHT
     *  1 : Postive VCC Negtaive GND, 2 : Postive GND Negtaive VCC.
     */
void Motor::Direction(int move) {
     if(move == 1){
     _positive = 1;
     _negative = 0;
    }
    else if(move == 2){   
     _positive = 0;
     _negative = 1;
        }
    }//End of Direction
   
     /* No input.
     *  1 : Postive GND Negtaive GND  
     */
void Motor::Stop() {
     _positive = 0;
     _negative = 0;
    }//End of Stop
    
void Motor::Speed(int motor_speed) {
   //float percantage = motor_speed/100;

    }//End of Speed