ARSLab / ParallaxRobotShield-v2
Embed: (wiki syntax)

« Back to documentation index

ParallaxRobotShield Class Reference

ParallaxRobotShield Class Reference

Parallax Robot Shield Control Class. More...

#include <ParallaxRobotShield.h>

Public Member Functions

 ParallaxRobotShield (PinName leftServoPin=D10, PinName rightServoPin=D11, PinName leftWhiskerPin=NC, PinName rightWhiskerPin=NC)
 Create a new ParallaxRobotShield object on any mbed pin.
void left_servo (int speed)
 Change the position of the servo.
void right_servo (int speed)
 Switch on the right servo at the given speed.
void forward (int speed)
 Switch on both servomotors, forwards at the given speed.
void backward (int speed)
 Switch on both servomotors, backwards at the given speed.
void left (int speed)
 Switch on both servomotors at the given speed, in opposite directions so as to turn left.
void right (int speed)
 Switch on both servomotors at the given speed, in opposite directions so as to turn right.
void turn_left (int speed)
 Turns left.
void turn_right (int speed)
 Turns right.
void disable_left_motor ()
 Disable the left motor.
void disable_right_motor ()
 Disable the right servomotor.
void enable_left_motor ()
 Enable the left servomotor.
void enable_right_motor ()
 Enable the left servomotor.
void stop (int motor)
 Stop a chosen motor.
void stopLeft ()
 Stop left servomotor.
void stopRight ()
 Stop right servomotor.
void stopAll ()
 Stop both servomotors at the same time.
float line_position ()
 Gives an indication of the data given by the reflectivity sensors.
int leftWhiskerContact ()
 Turns on the appropriate LED to signal if the corresponding whisker is in contact.
int rightWhiskerContact ()
 Returns an integer corresponding to the state of the right whisker.
void whisker ()
 Controls the servomotors accordingly if the whiskers come in contact.

Detailed Description

Parallax Robot Shield Control Class.

Definition at line 7 of file ParallaxRobotShield.h.


Constructor & Destructor Documentation

ParallaxRobotShield ( PinName  leftServoPin = D10,
PinName  rightServoPin = D11,
PinName  leftWhiskerPin = NC,
PinName  rightWhiskerPin = NC 
)

Create a new ParallaxRobotShield object on any mbed pin.

Parameters:
leftServoPinLeft Servomotor Signal pin
rightServoPinRight Servomotor Signal pin Create a new ParallaxRobotShield object on any mbed pin
leftServoPinLeft Servomotor Signal pin - default D10
rightServoPinRight Servomotor Signal pin - - default D11
leftWhiskerPinWhisker digital pin connection
rightWhiskerPinWhisker digital pin connection

Definition at line 10 of file ParallaxRobotShield.cpp.


Member Function Documentation

void backward ( int  speed )

Switch on both servomotors, backwards at the given speed.

Parameters:
speedThe speed, from 0 to 100 at which to spin the servomotors.

Definition at line 104 of file ParallaxRobotShield.cpp.

void disable_left_motor (  )

Disable the left motor.

Definition at line 36 of file ParallaxRobotShield.cpp.

void disable_right_motor (  )

Disable the right servomotor.

Definition at line 44 of file ParallaxRobotShield.cpp.

void enable_left_motor (  )

Enable the left servomotor.

Definition at line 50 of file ParallaxRobotShield.cpp.

void enable_right_motor (  )

Enable the left servomotor.

Definition at line 58 of file ParallaxRobotShield.cpp.

void forward ( int  speed )

Switch on both servomotors, forwards at the given speed.

Parameters:
speedThe speed, from 0 to 100 at which to spin the servomotors.

Definition at line 92 of file ParallaxRobotShield.cpp.

void left ( int  speed )

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

Parameters:
speedThe speed, from 0 to 100 at which to spin the servomotors.

Definition at line 110 of file ParallaxRobotShield.cpp.

void left_servo ( int  speed )

Change the position of the servo.

Position in us.

Parameters:
NewPosThe new value of the servos position (us) Enable the servo. Without enabling, the servo won't be running. Startposition and period both in us.
StartPosThe position of the servo to start (us)
PeriodThe time between every pulse. 20000 us = 50 Hz(standard) (us) Disable the servo. After disabling the servo won't get any signal anymore Create a robot shield object************************************************************************************************
leftServoLeft Servomotor Signal pin, default D13
rightServoPinRightServomotor Signal pin, default D14
whiskerWhisker digital pin connection, default D7
lightSensorSensor signal pin, default D6
bumpSensorSensor signal pin, default D5
HCSR04sensorSensor in-right pin, default D4 // For later - Need Trigger and RCC Switch on the left servo at the given speed. Can be used with loops to run the left servomotor.
speedThe speed, from 0 to 100 at which to spin the servomotor.

Definition at line 17 of file ParallaxRobotShield.cpp.

int leftWhiskerContact (  )

Turns on the appropriate LED to signal if the corresponding whisker is in contact.

Returns an integer corresponding to the state of the left whisker.

Returns:
1 if the Left whisker is in contact, 0 otherwise.

Definition at line 167 of file ParallaxRobotShield.cpp.

float line_position (  )

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

*************************************************************************************

void right ( int  speed )

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

Parameters:
speedThe speed, from 0 to 100 at which to spin the servomotors.

Definition at line 122 of file ParallaxRobotShield.cpp.

void right_servo ( int  speed )

Switch on the right servo at the given speed.

Can be used with loops to run the right servomotor.

Parameters:
speedThe speed, from 0 to 100 at which to spin the servomotor.

Definition at line 24 of file ParallaxRobotShield.cpp.

int rightWhiskerContact (  )

Returns an integer corresponding to the state of the right whisker.

Returns:
1 if the Right whisker is in contact, 0 otherwise.

Definition at line 176 of file ParallaxRobotShield.cpp.

void stop ( int  motor )

Stop a chosen motor.

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

Definition at line 139 of file ParallaxRobotShield.cpp.

void stopAll (  )

Stop both servomotors at the same time.

Different from disable.

Definition at line 148 of file ParallaxRobotShield.cpp.

void stopLeft (  )

Stop left servomotor.

Definition at line 128 of file ParallaxRobotShield.cpp.

void stopRight (  )

Stop right servomotor.

Definition at line 133 of file ParallaxRobotShield.cpp.

void turn_left ( int  speed )

Turns left.

Parameters:
speedThe speed, from 0 to 100 at which to spin the servomotors.

Definition at line 66 of file ParallaxRobotShield.cpp.

void turn_right ( int  speed )

Turns right.

Parameters:
speedThe speed, from 0 to 100 at which to spin the servomotors.

Definition at line 79 of file ParallaxRobotShield.cpp.

void whisker (  )

Controls the servomotors accordingly if the whiskers come in contact.