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 Components

Committer:
melse
Date:
Mon Jul 15 13:53:22 2013 +0000
Revision:
4:e2d5ac8459a4
Parent:
3:ccd47cdacb7b
Child:
5:179e85a68446
Lots more documentation

Who changed what in which revision?

UserRevisionLine numberNew 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 4:e2d5ac8459a4 12 * @param speed The speed, from 0.0 to 1.0 at which to spin the motor.
melse 2:118efce95f3c 13 */
melse 0:227158f56a11 14 void left_motor(float speed);
melse 4:e2d5ac8459a4 15
melse 4:e2d5ac8459a4 16 /** Switch on the right motor at the given speed.
melse 4:e2d5ac8459a4 17 * @param speed The speed, from 0.0 to 1.0 at which to spin the motor.
melse 4:e2d5ac8459a4 18 */
melse 0:227158f56a11 19 void right_motor(float speed);
melse 0:227158f56a11 20
melse 4:e2d5ac8459a4 21 /** Switch on both motors, forwards at the given speed.
melse 4:e2d5ac8459a4 22 * @param speed The speed, from 0.0 to 1.0 at which to spin the motor.
melse 4:e2d5ac8459a4 23 */
melse 0:227158f56a11 24 void forward(float speed);
melse 4:e2d5ac8459a4 25
melse 4:e2d5ac8459a4 26 /** Switch on both motors, backwards at the given speed.
melse 4:e2d5ac8459a4 27 * @param speed The speed, from 0.0 to 1.0 at which to spin the motor.
melse 4:e2d5ac8459a4 28 */
melse 0:227158f56a11 29 void backward(float speed);
melse 0:227158f56a11 30
melse 4:e2d5ac8459a4 31 /** Switch on both motors at the given speed, in opposite directions so as to turn left.
melse 4:e2d5ac8459a4 32 * @param speed The speed, from 0.0 to 1.0 at which to spin the motors.
melse 4:e2d5ac8459a4 33 */
melse 0:227158f56a11 34 void left(float speed);
melse 4:e2d5ac8459a4 35
melse 4:e2d5ac8459a4 36 /** Switch on both motors at the given speed, in opposite directions so as to turn right.
melse 4:e2d5ac8459a4 37 * @param speed The speed, from 0.0 to 1.0 at which to spin the motors.
melse 4:e2d5ac8459a4 38 */
melse 0:227158f56a11 39 void right(float speed);
melse 0:227158f56a11 40
melse 4:e2d5ac8459a4 41 /** Disable the left motor, by driving enable pin for the second motor low...
melse 4:e2d5ac8459a4 42 */
melse 2:118efce95f3c 43 void disable_left_motor();
melse 4:e2d5ac8459a4 44
melse 4:e2d5ac8459a4 45 /** Disable the left motor, by driving enable pin for the first motor low...
melse 4:e2d5ac8459a4 46 */
melse 2:118efce95f3c 47 void disable_right_motor();
melse 0:227158f56a11 48
melse 4:e2d5ac8459a4 49 /** Enable the left motor, by driving enable pin for the second motor high...
melse 4:e2d5ac8459a4 50 */
melse 2:118efce95f3c 51 void enable_left_motor();
melse 4:e2d5ac8459a4 52
melse 4:e2d5ac8459a4 53 /** Enable the left motor, by driving enable pin for the first motor high...
melse 4:e2d5ac8459a4 54 */
melse 2:118efce95f3c 55 void enable_right_motor();
melse 0:227158f56a11 56
melse 4:e2d5ac8459a4 57 /** Stop both motors at the same time. Different to disable.
melse 4:e2d5ac8459a4 58 */
melse 0:227158f56a11 59 void stopAll();
melse 4:e2d5ac8459a4 60
melse 4:e2d5ac8459a4 61 /** Stop a chosen motor.
melse 4:e2d5ac8459a4 62 * @param motor Number, either 1 or 2 choosing the motor.
melse 4:e2d5ac8459a4 63 */
melse 2:118efce95f3c 64 void stop(int motor);
melse 0:227158f56a11 65
melse 0:227158f56a11 66 // Need to do something to do with detected line...
melse 0:227158f56a11 67
melse 4:e2d5ac8459a4 68 /** Gives an indication of the data given by the reflectivity sensors.
melse 4:e2d5ac8459a4 69 */
melse 1:5c40f2a5e1ac 70 float line_position();
melse 0:227158f56a11 71
melse 0:227158f56a11 72 DigitalIn rightSensor;
melse 0:227158f56a11 73 DigitalIn inRightSensor;
melse 0:227158f56a11 74 DigitalIn centreSensor;
melse 0:227158f56a11 75 DigitalIn inLeftSensor;
melse 0:227158f56a11 76 DigitalIn leftSensor;
melse 0:227158f56a11 77
melse 0:227158f56a11 78 private:
melse 0:227158f56a11 79 PwmOut motor1A;
melse 0:227158f56a11 80 DigitalOut motor1B;
melse 0:227158f56a11 81 DigitalOut motor1En;
melse 0:227158f56a11 82
melse 0:227158f56a11 83 // motor2A or motor2B need to be PWM, but the freedom board doesn't support it at the moment...
melse 0:227158f56a11 84 PwmOut motor2A;
melse 0:227158f56a11 85 DigitalOut motor2B;
melse 0:227158f56a11 86 DigitalOut motor2En;
melse 0:227158f56a11 87 };