na
Fork of SeeedShieldBot by
Diff: SeeedStudioShieldBot.cpp
- Revision:
- 2:118efce95f3c
- Parent:
- 1:5c40f2a5e1ac
- Child:
- 7:887c729fd7c1
diff -r 5c40f2a5e1ac -r 118efce95f3c SeeedStudioShieldBot.cpp --- a/SeeedStudioShieldBot.cpp Mon Jul 15 13:38:07 2013 +0000 +++ b/SeeedStudioShieldBot.cpp Mon Jul 15 13:47:09 2013 +0000 @@ -2,17 +2,17 @@ #include "mbed.h" -SeeedStudioShieldBot::SeeedStudioShieldBot() : motor1A(PTA5), - motor1B(PTC9), - motor2A(PTA12), - motor2B(PTD0), - motor1En(PTC8), - motor2En(PTD5), - rightSensor(PTB0), +SeeedStudioShieldBot::SeeedStudioShieldBot() : rightSensor(PTB0), inRightSensor(PTB1), centreSensor(PTB2), inLeftSensor(PTB3), - leftSensor(PTA4) { + leftSensor(PTA4), + motor1A(PTA5), + motor1B(PTC9), + motor1En(PTC8), + motor2A(PTA12), + motor2B(PTD0), + motor2En(PTD5) { // Something should go here... } @@ -80,19 +80,19 @@ } } -void SeeedStudioShieldBot::enable_motor_a() { +void SeeedStudioShieldBot::enable_right_motor() { motor1En = 1; } -void SeeedStudioShieldBot::enable_motor_b() { +void SeeedStudioShieldBot::enable_left_motor() { motor2En = 1; } -void SeeedStudioShieldBot::disable_motor_a() { +void SeeedStudioShieldBot::disable_right_motor() { motor1En = 0; } -void SeeedStudioShieldBot::disable_motor_b() { +void SeeedStudioShieldBot::disable_left_motor() { motor2En = 0; } @@ -122,4 +122,16 @@ motor1B = 0; motor2A = 0; motor2B = 0; +} + +void SeeedStudioShieldBot::stop(int motor) { + if (motor == 1) { + // Stop motor 0... + motor1A = 0; + motor1B = 0; + } + else if (motor == 2) { + motor2A = 0; + motor2B = 0; + } } \ No newline at end of file