Library for the Shield Bot by SeeedStudio
Dependents: Seeed_Bot_Shield Seeed_BlueBot_demo Seeed_BlueBot_demo_test1 LAB03_Oppgav1 ... more
Fork of SeeedShieldBot by
Revision 2:118efce95f3c, committed 2013-07-15
- Comitter:
- melse
- Date:
- Mon Jul 15 13:47:09 2013 +0000
- Parent:
- 1:5c40f2a5e1ac
- Child:
- 3:ccd47cdacb7b
- Commit message:
- added more docs
Changed in this revision
SeeedStudioShieldBot.cpp | Show annotated file Show diff for this revision Revisions of this file |
SeeedStudioShieldBot.h | Show annotated file Show diff for this revision Revisions of this file |
--- 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
--- a/SeeedStudioShieldBot.h Mon Jul 15 13:38:07 2013 +0000 +++ b/SeeedStudioShieldBot.h Mon Jul 15 13:47:09 2013 +0000 @@ -6,6 +6,8 @@ // Create a shield bot object, using default settings for now... SeeedStudioShieldBot(); + /** Switch on the left motor at the given speed. + */ void left_motor(float speed); void right_motor(float speed); @@ -18,13 +20,14 @@ void left(float speed); void right(float speed); - void disable_motor_a(); - void disable_motor_b(); + void disable_left_motor(); + void disable_right_motor(); - void enable_motor_a(); - void enable_motor_b(); + void enable_left_motor(); + void enable_right_motor(); void stopAll(); + void stop(int motor); // Need to do something to do with detected line...