Colour sensors calibrated
Dependencies: mbed-rtos mbed Servo QEI
Fork of ICRSEurobot13 by
Actuators/MainMotors/MainMotor.h@46:adcd57a5e402, 2013-04-12 (annotated)
- Committer:
- xiaxia686
- Date:
- Fri Apr 12 20:59:18 2013 +0000
- Revision:
- 46:adcd57a5e402
- Parent:
- 5:56a5fdd373c9
Colours Sensors fixed
Who changed what in which revision?
User | Revision | Line number | New 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 | }; |