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.
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:
-
leftServoPin Left Servomotor Signal pin rightServoPin Right Servomotor Signal pin Create a new ParallaxRobotShield object on any mbed pin leftServoPin Left Servomotor Signal pin - default D10 rightServoPin Right Servomotor Signal pin - - default D11 leftWhiskerPin Whisker digital pin connection rightWhiskerPin Whisker 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:
-
speed The 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:
-
speed The 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:
-
speed The 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:
-
NewPos The new value of the servos position (us) Enable the servo. Without enabling, the servo won't be running. Startposition and period both in us. StartPos The position of the servo to start (us) Period The 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************************************************************************************************ leftServo Left Servomotor Signal pin, default D13 rightServoPin RightServomotor Signal pin, default D14 whisker Whisker digital pin connection, default D7 lightSensor Sensor signal pin, default D6 bumpSensor Sensor signal pin, default D5 HCSR04sensor Sensor 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. speed The 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:
-
speed The 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:
-
speed The 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:
-
motor Number, 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:
-
speed The 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:
-
speed The 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.
Generated on Fri Jul 22 2022 01:44:31 by
1.7.2