328 Motor and Servo Functions
The Arduino MEGA has 12 ports available for PWM generation. These ports can be used control motors and servos to extend the capabilities of your Arduino system. Users can use the "Motors and Sensor Setup" utility (found under the Robot menu) to configure their ports for the various types of motors:
Hardware Timing Servo Ports - Pin 2, 3, 5, 6, 7, 8, 11, 12 and 13.
Hardware Timing PWM (H-Bridge Friendly) Ports - Pin 4, 9 and 10.
Available Motor Types
|
Contents |
|
bMotorReflected
bool bMotorReflected | |
(bool) Boolean array with one entry for each motor. Indicates that the direction of a motor should be reflected 180 degrees. Useful when mechanical design results in a logical "reversed" condition of a motor. | |
|
motor
int motor[tMotor motor] | ||||||
(int) An array variable with one element for each of the possible motors.
When used with a motor, this command is used to set the speed (-127 to +127) for a motor. Negative values are reverse; positive forward. Zero is stopped. When used with a servo, this command is used to set the position (-127 to +127) of the servo. Zero is the "center" position of the servo, and -127 to +127 is the range of the servo. Note that your servo may not be able to travel the full -127 to +127 range, so please experiment with smaller values to avoid breaking your servo. | ||||||
| ||||||
|