| upm
    1.7.1
    Sensor/Actuator repository for libmraa (v2.0.0) | 
API for the L298 Dual H-Bridge Motor Driver. More...
It was developed using the RobotBase Dual H-Bridge module.
This module can support 2 DC motors, or one 2-phase stepper motor. It requires 3 pins per DC motor (or H-bridge), or 4 pins for the stepper motor (uses both H-bridges).
 
 
L298 Dual H-Bridge Motor Driver image provided by SparkFun* under CC BY 2.0.
Example driving a DC motor
Example driving a stepper motor
| Public Types | |
| enum | L298_DIRECTION_T { DIR_NONE = 0x00, DIR_CW = 0x01, DIR_CCW = 0x02 } | 
| Public Member Functions | |
| L298 (int pwm, int dir1, int dir2) | |
| L298 (int stepsPerRev, int en, int i1, int i2, int i3, int i4) | |
| ~L298 () | |
| uint32_t | getMillis () | 
| void | initClock () | 
| void | setPeriodMS (int ms) | 
| void | enable (bool enable) | 
| void | setSpeed (int speed) | 
| void | setDirection (L298_DIRECTION_T dir) | 
| void | stepperSteps (unsigned int steps) | 
| enum L298_DIRECTION_T | 
Enum to specify the direction of a motor
| L298 | ( | int | pwm, | 
| int | dir1, | ||
| int | dir2 | ||
| ) | 
L298 constructor for DC motor(s) connected.
| pwm | Digital pin to use for a DC motor - must be PWM-capable | 
| dir1 | Digital pin to use for motor direction pin 1 | 
| dir2 | Digital pin to use for motor direction pin 2 | 
| L298 | ( | int | stepsPerRev, | 
| int | en, | ||
| int | i1, | ||
| int | i2, | ||
| int | i3, | ||
| int | i4 | ||
| ) | 
L298 constructor for a 4-wire stepper motor
| stepsPerRev | Number of steps per full revolution | 
| en | Enables the pin | 
| i1 | Digital pin to use for stepper input 1 | 
| i2 | Digital pin to use for stepper input 2 | 
| i3 | Digital pin to use for stepper input 3 | 
| i4 | Digital pin to use for stepper input 4 | 
| uint32_t getMillis | ( | ) | 
Returns the number of milliseconds elapsed since initClock() was last called.
| void initClock | ( | ) | 
Resets the clock
| void setPeriodMS | ( | int | ms | ) | 
Sets the period in milliseconds
| ms | Period in milliseconds | 
| void enable | ( | bool | enable | ) | 
Enables the PWM output for a motor
| enable | Enables the PWM output if true, disables if false | 
| void setSpeed | ( | int | speed | ) | 
Sets the speed of a DC or stepper motor. For a DC motor, values can range from 0 (off) to 100 (full speed). For a stepper motor, specify the desired RPM.
| speed | Speed to set the motor to | 
| void setDirection | ( | L298_DIRECTION_T | dir | ) | 
Sets the direction of the motor, clockwise or counterclockwise
| dir | Direction to set the motor to | 
| void stepperSteps | ( | unsigned int | steps | ) | 
Steps the stepper motor a specified number of steps
| steps | Number of steps to move the stepper motor | 
 1.8.11
 1.8.11