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:55:44 2013 +0000
Revision:
5:179e85a68446
Parent:
4:e2d5ac8459a4
Child:
6:9479362be27f
more docu

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