Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
SeeedStudioShieldBot.h
00001 #include "mbed.h" 00002 00003 /** Seeed Studio Shield Bot Control Class 00004 * 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. 00005 * Also, in order to provide power to the freedom board, when running just of a lipo battery, you need to connect between 5V and VIN on the shield bot. 00006 * Code/notes above only tested with version 0.9b, may not be needed/may not work in other cases... 00007 */ 00008 class SeeedStudioShieldBot { 00009 public: 00010 00011 // Create a shield bot object, using default settings for now... 00012 SeeedStudioShieldBot(); 00013 00014 /** Switch on the left motor at the given speed. 00015 * @param speed The speed, from 0.0 to 1.0 at which to spin the motor. 00016 */ 00017 void left_motor(float speed); 00018 00019 /** Switch on the right motor at the given speed. 00020 * @param speed The speed, from 0.0 to 1.0 at which to spin the motor. 00021 */ 00022 void right_motor(float speed); 00023 00024 /** Switch on both motors, forwards at the given speed. 00025 * @param speed The speed, from 0.0 to 1.0 at which to spin the motor. 00026 */ 00027 void forward(float speed); 00028 00029 /** Switch on both motors, backwards at the given speed. 00030 * @param speed The speed, from 0.0 to 1.0 at which to spin the motor. 00031 */ 00032 void backward(float speed); 00033 00034 /** Switch on both motors at the given speed, in opposite directions so as to turn left. 00035 * @param speed The speed, from 0.0 to 1.0 at which to spin the motors. 00036 */ 00037 void left(float speed); 00038 00039 /** Switch on both motors at the given speed, in opposite directions so as to turn right. 00040 * @param speed The speed, from 0.0 to 1.0 at which to spin the motors. 00041 */ 00042 void right(float speed); 00043 00044 /** Disable the left motor, by driving enable pin for the second motor low... 00045 */ 00046 void disable_left_motor(); 00047 00048 /** Disable the left motor, by driving enable pin for the first motor low... 00049 */ 00050 void disable_right_motor(); 00051 00052 /** Enable the left motor, by driving enable pin for the second motor high... 00053 */ 00054 void enable_left_motor(); 00055 00056 /** Enable the left motor, by driving enable pin for the first motor high... 00057 */ 00058 void enable_right_motor(); 00059 00060 /** Stop both motors at the same time. Different to disable. 00061 */ 00062 void stopAll(); 00063 00064 /** Stop a chosen motor. 00065 * @param motor Number, either 1 or 2 choosing the motor. 00066 */ 00067 void stop(int motor); 00068 00069 // Need to do something to do with detected line... 00070 00071 /** Gives an indication of the data given by the reflectivity sensors. 00072 */ 00073 float line_position(); 00074 00075 DigitalIn rightSensor; 00076 DigitalIn inRightSensor; 00077 DigitalIn centreSensor; 00078 DigitalIn inLeftSensor; 00079 DigitalIn leftSensor; 00080 00081 private: 00082 PwmOut motor1A; 00083 DigitalOut motor1B; 00084 DigitalOut motor1En; 00085 00086 // motor2A or motor2B need to be PWM, but the freedom board doesn't support it at the moment... 00087 PwmOut motor2A; 00088 DigitalOut motor2B; 00089 DigitalOut motor2En; 00090 };
Generated on Wed Jul 20 2022 04:25:07 by
1.7.2
Seeed Studio Shield Bot