na
Fork of SeeedShieldBot by
SeeedStudioShieldBot.h@3:ccd47cdacb7b, 2013-07-15 (annotated)
- Committer:
- melse
- Date:
- Mon Jul 15 13:48:10 2013 +0000
- Revision:
- 3:ccd47cdacb7b
- Parent:
- 2:118efce95f3c
- Child:
- 4:e2d5ac8459a4
added more docs
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
melse | 0:227158f56a11 | 1 | #include "mbed.h" |
melse | 0:227158f56a11 | 2 | |
melse | 3:ccd47cdacb7b | 3 | /** Seeed Studio Shield Bot Control Class |
melse | 3:ccd47cdacb7b | 4 | */ |
melse | 0:227158f56a11 | 5 | class SeeedStudioShieldBot { |
melse | 0:227158f56a11 | 6 | public: |
melse | 0:227158f56a11 | 7 | |
melse | 0:227158f56a11 | 8 | // Create a shield bot object, using default settings for now... |
melse | 0:227158f56a11 | 9 | SeeedStudioShieldBot(); |
melse | 0:227158f56a11 | 10 | |
melse | 2:118efce95f3c | 11 | /** Switch on the left motor at the given speed. |
melse | 2:118efce95f3c | 12 | */ |
melse | 0:227158f56a11 | 13 | void left_motor(float speed); |
melse | 0:227158f56a11 | 14 | void right_motor(float speed); |
melse | 0:227158f56a11 | 15 | |
melse | 0:227158f56a11 | 16 | // Like the two above, but both at the same speed. |
melse | 0:227158f56a11 | 17 | // Negative of either will do the same job as the other (hopefully...) |
melse | 0:227158f56a11 | 18 | void forward(float speed); |
melse | 0:227158f56a11 | 19 | void backward(float speed); |
melse | 0:227158f56a11 | 20 | |
melse | 0:227158f56a11 | 21 | // This will rotate both of the motors in opposite directions, at the same speed |
melse | 0:227158f56a11 | 22 | void left(float speed); |
melse | 0:227158f56a11 | 23 | void right(float speed); |
melse | 0:227158f56a11 | 24 | |
melse | 2:118efce95f3c | 25 | void disable_left_motor(); |
melse | 2:118efce95f3c | 26 | void disable_right_motor(); |
melse | 0:227158f56a11 | 27 | |
melse | 2:118efce95f3c | 28 | void enable_left_motor(); |
melse | 2:118efce95f3c | 29 | void enable_right_motor(); |
melse | 0:227158f56a11 | 30 | |
melse | 0:227158f56a11 | 31 | void stopAll(); |
melse | 2:118efce95f3c | 32 | void stop(int motor); |
melse | 0:227158f56a11 | 33 | |
melse | 0:227158f56a11 | 34 | // Need to do something to do with detected line... |
melse | 0:227158f56a11 | 35 | |
melse | 1:5c40f2a5e1ac | 36 | float line_position(); |
melse | 0:227158f56a11 | 37 | |
melse | 0:227158f56a11 | 38 | DigitalIn rightSensor; |
melse | 0:227158f56a11 | 39 | DigitalIn inRightSensor; |
melse | 0:227158f56a11 | 40 | DigitalIn centreSensor; |
melse | 0:227158f56a11 | 41 | DigitalIn inLeftSensor; |
melse | 0:227158f56a11 | 42 | DigitalIn leftSensor; |
melse | 0:227158f56a11 | 43 | |
melse | 0:227158f56a11 | 44 | private: |
melse | 0:227158f56a11 | 45 | PwmOut motor1A; |
melse | 0:227158f56a11 | 46 | DigitalOut motor1B; |
melse | 0:227158f56a11 | 47 | DigitalOut motor1En; |
melse | 0:227158f56a11 | 48 | |
melse | 0:227158f56a11 | 49 | // motor2A or motor2B need to be PWM, but the freedom board doesn't support it at the moment... |
melse | 0:227158f56a11 | 50 | PwmOut motor2A; |
melse | 0:227158f56a11 | 51 | DigitalOut motor2B; |
melse | 0:227158f56a11 | 52 | DigitalOut motor2En; |
melse | 0:227158f56a11 | 53 | }; |