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

Embed: (wiki syntax)

« Back to documentation index

SeeedStudioShieldBot Class Reference

SeeedStudioShieldBot Class Reference

Seeed Studio Shield Bot Control Class 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. More...

#include <SeeedStudioShieldBot.h>

Public Member Functions

 SeeedStudioShieldBot (PinName mot1A, PinName mot1En, PinName mot1B, PinName mot2A, PinName mot2En, PinName mot2B, PinName sensor_right, PinName sensor_inright, PinName sensor_center, PinName sensor_inleft, PinName sensor_left)
 Create a shield bot object.
void left_motor (float speed)
 Switch on the left motor at the given speed.
void right_motor (float speed)
 Switch on the right motor at the given speed.
void forward (float speed)
 Switch on both motors, forwards at the given speed.
void backward (float speed)
 Switch on both motors, backwards at the given speed.
void left (float speed)
 Switch on both motors at the given speed, in opposite directions so as to turn left.
void right (float speed)
 Switch on both motors at the given speed, in opposite directions so as to turn right.
void turn_left (float speed)
 Turns left.
void turn_right (float speed)
 Turns right.
void disable_left_motor ()
 Disable the left motor, by driving enable pin for the second motor low...
void disable_right_motor ()
 Disable the left motor, by driving enable pin for the first motor low...
void enable_left_motor ()
 Enable the left motor, by driving enable pin for the second motor high...
void enable_right_motor ()
 Enable the left motor, by driving enable pin for the first motor high...
void stop (int motor)
 Stop a chosen motor.
void stopLeft ()
 Stop left motor.
void stopRight ()
 Stop right motor.
void stopAll ()
 Stop both motors at the same time.
float line_position ()
 Gives an indication of the data given by the reflectivity sensors.

Detailed Description

Seeed Studio Shield Bot Control Class 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.

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. Code/notes above only tested with version 0.9b, may not be needed/may not work in other cases...

Definition at line 8 of file SeeedStudioShieldBot.h.


Constructor & Destructor Documentation

SeeedStudioShieldBot ( PinName  mot1A,
PinName  mot1En,
PinName  mot1B,
PinName  mot2A,
PinName  mot2En,
PinName  mot2B,
PinName  sensor_right,
PinName  sensor_inright,
PinName  sensor_center,
PinName  sensor_inleft,
PinName  sensor_left 
)

Create a shield bot object.

Parameters:
mot1ALeft Motor A pin, default D5
mot1BLeft Motor B pin, default D6
mot1EnLeft Motor enable pin, default D7
mot2ARight Motor A pin, default D8
mot2BRight Motor B pin, default D9
mot2EnRight Motor enable pin, default D10
sensor_rightSensor right pin, default A0
sensor_inrightSensor in-right pin, default A1
sensor_centerSensor right pin, default A2
sensor_inleftSensor in-left pin, default A3
sensor_leftSensor left pin, default D4

Definition at line 5 of file SeeedStudioShieldBot.cpp.


Member Function Documentation

void backward ( float  speed )

Switch on both motors, backwards at the given speed.

Parameters:
speedThe speed, from 0.0 to 1.0 at which to spin the motor.

Definition at line 84 of file SeeedStudioShieldBot.cpp.

void disable_left_motor (  )

Disable the left motor, by driving enable pin for the second motor low...

Definition at line 110 of file SeeedStudioShieldBot.cpp.

void disable_right_motor (  )

Disable the left motor, by driving enable pin for the first motor low...

Definition at line 105 of file SeeedStudioShieldBot.cpp.

void enable_left_motor (  )

Enable the left motor, by driving enable pin for the second motor high...

Definition at line 100 of file SeeedStudioShieldBot.cpp.

void enable_right_motor (  )

Enable the left motor, by driving enable pin for the first motor high...

Definition at line 95 of file SeeedStudioShieldBot.cpp.

void forward ( float  speed )

Switch on both motors, forwards at the given speed.

Parameters:
speedThe speed, from 0.0 to 1.0 at which to spin the motor.

Definition at line 73 of file SeeedStudioShieldBot.cpp.

void left ( float  speed )

Switch on both motors at the given speed, in opposite directions so as to turn left.

Parameters:
speedThe speed, from 0.0 to 1.0 at which to spin the motors.

Definition at line 43 of file SeeedStudioShieldBot.cpp.

void left_motor ( float  speed )

Switch on the left motor at the given speed.

Parameters:
speedThe speed, from 0.0 to 1.0 at which to spin the motor.

Definition at line 29 of file SeeedStudioShieldBot.cpp.

float line_position (  )

Gives an indication of the data given by the reflectivity sensors.

Definition at line 118 of file SeeedStudioShieldBot.cpp.

void right ( float  speed )

Switch on both motors at the given speed, in opposite directions so as to turn right.

Parameters:
speedThe speed, from 0.0 to 1.0 at which to spin the motors.

Definition at line 49 of file SeeedStudioShieldBot.cpp.

void right_motor ( float  speed )

Switch on the right motor at the given speed.

Parameters:
speedThe speed, from 0.0 to 1.0 at which to spin the motor.

Definition at line 17 of file SeeedStudioShieldBot.cpp.

void stop ( int  motor )

Stop a chosen motor.

Parameters:
motorNumber, either 1 or 2 choosing the motor.

Definition at line 137 of file SeeedStudioShieldBot.cpp.

void stopAll (  )

Stop both motors at the same time.

Different to disable.

Definition at line 158 of file SeeedStudioShieldBot.cpp.

void stopLeft (  )

Stop left motor.

Definition at line 146 of file SeeedStudioShieldBot.cpp.

void stopRight (  )

Stop right motor.

Definition at line 152 of file SeeedStudioShieldBot.cpp.

void turn_left ( float  speed )

Turns left.

Parameters:
speedThe speed, from 0.0 to 1.0 at which to spin the motor.

Definition at line 55 of file SeeedStudioShieldBot.cpp.

void turn_right ( float  speed )

Turns right.

Parameters:
speedThe speed, from 0.0 to 1.0 at which to spin the motor.

Definition at line 61 of file SeeedStudioShieldBot.cpp.