This is some awesome robot code

Dependencies:   mbed-rtos mbed QEI

Fork of ICRSEurobot13 by Thomas Branch

Embed: (wiki syntax)

« Back to documentation index

Show/hide line numbers MainMotor.h Source File

MainMotor.h

00001 
00002 // Eurobot13 MainMotor.h
00003 
00004 #include "mbed.h"
00005 
00006 class MainMotor{
00007     private:
00008     PwmOut PWM1;
00009     PwmOut PWM2;
00010     
00011     public:
00012     MainMotor(PinName pin1, PinName pin2) : PWM1(pin1), PWM2(pin2){
00013     }
00014     
00015     void operator()(float in){
00016         power(in);
00017     }
00018     
00019     void power(float power){
00020         if( power > 0 ){
00021             PWM1 = power;
00022             PWM2 = 0;
00023         } else {
00024             PWM1 = 0;
00025             PWM2 = -power;    
00026         }
00027     }
00028     
00029     virtual void halt (void){
00030         //DigitalOut myled(LED2);
00031         //myled = 1;
00032         PWM1 = 0;
00033         PWM2 = 0;
00034     }
00035 
00036 };