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.
Dependents: MUTTv1 ProvaMotoreSeriale SerialComLED motore2 ... more
ArduinoMotorShield Class Reference
Class to abstract the interface to an Arduino Motor Shield R3 See http://arduino.cc/en/Main/ArduinoMotorShieldR3. More...
#include <ArduinoMotorShield.hpp>
Public Types | |
| enum | Motor_e |
Enumeration to distinguish between the motors connected to the shield. More... | |
Public Member Functions | |
| ArduinoMotorShield () | |
| Constructor. | |
| void | SetMotorPower (const Motor_e p_motor, const float p_speed, bool p_force=false) |
| Set the motor power (and direction) for the specified motor. | |
| float | GetMotorCurrent (const Motor_e p_motor) |
| Retrieve the current being consumed by the specified motor. | |
| void | SetBrake (const Motor_e p_motor, bool p_enable) |
| Enable or disable the brake on the specified motor. | |
| void | SetMotorPolarity (const Motor_e p_motor, const MotorDirection_e p_dir) |
| Set the virtual 'polarity' of a motor. | |
Static Protected Attributes | |
| static const uint8_t | MOTOR_DRIVE_COUNT = 2U |
| Maximum number of motors which can be connected to the shield. | |
| static const uint8_t | MOTOR_MAX_CURRENT = 2U |
| Maximum current (per motor drive) supported by the shield. | |
Detailed Description
Class to abstract the interface to an Arduino Motor Shield R3 See http://arduino.cc/en/Main/ArduinoMotorShieldR3.
This class is a pretty thin wrapper around the analog inputs and digital outputs which interface to the motor drives
Currently supports: TARGET_KL46Z - Assumes the presence of the cross-wiring on PWM B (see "Issues" at http://mbed.org/users/johnb/notebook/mutt-mbed-enabled-robot-vehicle/ )
Definition at line 45 of file ArduinoMotorShield.hpp.
Member Enumeration Documentation
| enum Motor_e |
Enumeration to distinguish between the motors connected to the shield.
Definition at line 56 of file ArduinoMotorShield.hpp.
Constructor & Destructor Documentation
Constructor.
Member Function Documentation
| float GetMotorCurrent | ( | const Motor_e | p_motor ) |
Retrieve the current being consumed by the specified motor.
- Parameters:
-
p_motor The motor to retrieve the current for
Definition at line 95 of file ArduinoMotorShield.cpp.
| void SetBrake | ( | const Motor_e | p_motor, |
| bool | p_enable | ||
| ) |
Enable or disable the brake on the specified motor.
In the case that the braking option is enabled then (when appropriate) the shield will actively brake the motor rather than allowing it to coast down
- Parameters:
-
p_motor The motor to set the brake option for p_enable Specify whether braking should be enabled or disabled
Definition at line 101 of file ArduinoMotorShield.cpp.
| void SetMotorPolarity | ( | const Motor_e | p_motor, |
| const MotorDirection_e | p_dir | ||
| ) |
Set the virtual 'polarity' of a motor.
This allows you to swap the meaning of "forward" with respect to the SetMotorPower() method. For example:
shield.SetMotorPolarity( MOTOR_A, MOTOR_FORWARD ); shield.SetMotorPower( MOTOR_A, 1.0F ); This call will cause the motor to change direction ! shield.SetMotorPolarity( MOTOR_A, MOTOR_BACKWARD ); No further change is caused by this call shield.SetMotorPower( MOTOR_A, 1.0F );
- Parameters:
-
p_motor The motor to change the direction setting for p_dir The direction which "forward" should map to.
Definition at line 106 of file ArduinoMotorShield.cpp.
| void SetMotorPower | ( | const Motor_e | p_motor, |
| const float | p_speed, | ||
| bool | p_force = false |
||
| ) |
Set the motor power (and direction) for the specified motor.
- Parameters:
-
p_motor Use this parameter to specify which motor to set the power on p_speed Set the power of the motor, ranging from -1 (full power, reverse direction) to +1 (full power, forward direction)
Definition at line 78 of file ArduinoMotorShield.cpp.
Field Documentation
const uint8_t MOTOR_DRIVE_COUNT = 2U [static, protected] |
Maximum number of motors which can be connected to the shield.
Definition at line 66 of file ArduinoMotorShield.hpp.
const uint8_t MOTOR_MAX_CURRENT = 2U [static, protected] |
Maximum current (per motor drive) supported by the shield.
Definition at line 69 of file ArduinoMotorShield.hpp.
Generated on Thu Jul 14 2022 01:30:41 by
1.7.2
Arduino Motor Shield V3