![](/media/cache/img/default_profile.jpg.50x50_q85.jpg)
This is some awesome robot code
Dependencies: mbed-rtos mbed QEI
Fork of ICRSEurobot13 by
Actuators/MainMotors/MainMotor.h@90:e4164bb8c60e, 2013-04-17 (annotated)
- Committer:
- madcowswe
- Date:
- Wed Apr 17 23:16:25 2013 +0000
- Revision:
- 90:e4164bb8c60e
- Parent:
- 5:56a5fdd373c9
final state at end of competition. Includes avoid wooden team hack
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 | }; |