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

Dependencies:   mbed

main.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"
/************************************* Lab4 Motor Control     ***************************/
/*                                                                                      */
/*  File: main.cpp                                                                      */
/*  Author: Ziad Eldebri                                                                */
/*  Date Created: 7/22/2016                                                             */
/*  Description: This is the basic Lab4 code. It uses the position of the variable resistor 
                    to control the motor speed and direction using L293 IC              */
/*                                                                                      */
/****************************************************************************************/
AnalogIn pot(PTB2);   // variable resistor middile pin
Motor my_motor(PTB1,PTB0); // create a motor object


int main() {

while (1) {  

//Stop if in the middle 
if((pot > 0.49) && (pot < 0.61)){
 my_motor.Stop();
      } 
      //Negative Direction 
      else if (pot < 0.48){
          my_motor.Direction(LEFT);
          wait(0.1);
          }
          //Postive Direction
      else if (pot > 0.62 ) {     
          my_motor.Direction(RIGHT);
          wait(0.1);
          }
    }
}