ICRS Eurobot 2013

Dependencies:   mbed mbed-rtos Servo QEI

Committer:
madcowswe
Date:
Tue Apr 09 15:33:36 2013 +0000
Revision:
20:70d651156779
Parent:
5:56a5fdd373c9
Predict loop running, update loop not done.

Who changed what in which revision?

UserRevisionLine numberNew contents of line
twighk 0:200635fa1b08 1
twighk 0:200635fa1b08 2 // Eurobot13 MainMotor.h
twighk 0:200635fa1b08 3
twighk 0:200635fa1b08 4 #include "mbed.h"
twighk 0:200635fa1b08 5
madcowswe 5:56a5fdd373c9 6 class MainMotor{
twighk 0:200635fa1b08 7 private:
twighk 0:200635fa1b08 8 PwmOut PWM1;
twighk 0:200635fa1b08 9 PwmOut PWM2;
twighk 0:200635fa1b08 10
twighk 0:200635fa1b08 11 public:
twighk 0:200635fa1b08 12 MainMotor(PinName pin1, PinName pin2) : PWM1(pin1), PWM2(pin2){
twighk 0:200635fa1b08 13 }
twighk 0:200635fa1b08 14
twighk 0:200635fa1b08 15 void operator()(float in){
twighk 0:200635fa1b08 16 power(in);
twighk 0:200635fa1b08 17 }
twighk 0:200635fa1b08 18
twighk 0:200635fa1b08 19 void power(float power){
twighk 0:200635fa1b08 20 if( power > 0 ){
twighk 0:200635fa1b08 21 PWM1 = power;
twighk 0:200635fa1b08 22 PWM2 = 0;
twighk 0:200635fa1b08 23 } else {
twighk 0:200635fa1b08 24 PWM1 = 0;
twighk 0:200635fa1b08 25 PWM2 = -power;
twighk 0:200635fa1b08 26 }
twighk 0:200635fa1b08 27 }
twighk 2:45da48fab346 28
twighk 2:45da48fab346 29 virtual void halt (void){
madcowswe 5:56a5fdd373c9 30 //DigitalOut myled(LED2);
madcowswe 5:56a5fdd373c9 31 //myled = 1;
twighk 2:45da48fab346 32 PWM1 = 0;
twighk 2:45da48fab346 33 PWM2 = 0;
twighk 2:45da48fab346 34 }
twighk 0:200635fa1b08 35
twighk 0:200635fa1b08 36 };