the fish that looks like a jet
Dependencies: ADXL345 ADXL345_I2C IMUfilter ITG3200 mbed Servo
motor_controller.cpp@12:7eeb29892625, 2014-02-01 (annotated)
- Committer:
- rkk
- Date:
- Sat Feb 01 00:03:40 2014 +0000
- Revision:
- 12:7eeb29892625
- Parent:
- 11:8ec915eb70f6
first design to put to water
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
sandwich | 0:ff9bc5f69c57 | 1 | #include "motor_controller.h" |
sandwich | 7:e005cfaff8d1 | 2 | |
sandwich | 0:ff9bc5f69c57 | 3 | PololuMController::PololuMController(PinName pwmport, PinName A, PinName B) |
rkk | 12:7eeb29892625 | 4 | :pwm(pwmport),outA(A),outB(B) |
rkk | 12:7eeb29892625 | 5 | { |
rkk | 11:8ec915eb70f6 | 6 | outA.write(0); |
rkk | 11:8ec915eb70f6 | 7 | outB.write(1); |
sandwich | 0:ff9bc5f69c57 | 8 | } |
sandwich | 0:ff9bc5f69c57 | 9 | |
sandwich | 0:ff9bc5f69c57 | 10 | void PololuMController::setpolarspeed(float speed) |
sandwich | 0:ff9bc5f69c57 | 11 | { |
rkk | 12:7eeb29892625 | 12 | if (speed>=0) { |
rkk | 11:8ec915eb70f6 | 13 | outA.write(0); |
rkk | 11:8ec915eb70f6 | 14 | outB.write(1); |
rkk | 11:8ec915eb70f6 | 15 | pwm.write(abs(speed)); |
rkk | 12:7eeb29892625 | 16 | } else { |
rkk | 11:8ec915eb70f6 | 17 | outA.write(1); |
rkk | 11:8ec915eb70f6 | 18 | outB.write(0); |
rkk | 11:8ec915eb70f6 | 19 | pwm.write(abs(speed)); |
sandwich | 0:ff9bc5f69c57 | 20 | } |
sandwich | 0:ff9bc5f69c57 | 21 | return; |
sandwich | 0:ff9bc5f69c57 | 22 | } |