L298 Class
- ID: l298
- Name: Dual H-bridge Motor Driver
- Category: motor
- Manufacturer: seeed sparkfun
- Link: https://www.sparkfun.com/products/9670
- Connection: gpio pwm
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).
Example driving a DC motor Example driving a stepper motor
Item Index
Methods
L298
-
pwm
-
dir1
-
dir2
L298 constructor for DC motor(s) connected.
Parameters:
-
pwm
NumberDigital pin to use for a DC motor - must be PWM-capable
-
dir1
NumberDigital pin to use for motor direction pin 1
-
dir2
NumberDigital pin to use for motor direction pin 2
Returns:
L298
-
stepsPerRev
-
en
-
i1
-
i2
-
i3
-
i4
L298 constructor for a 4-wire stepper motor
Parameters:
-
stepsPerRev
NumberNumber of steps per full revolution
-
en
NumberEnables the pin
-
i1
NumberDigital pin to use for stepper input 1
-
i2
NumberDigital pin to use for stepper input 2
-
i3
NumberDigital pin to use for stepper input 3
-
i4
NumberDigital pin to use for stepper input 4
Returns:
getMillis
()
Number
Returns the number of milliseconds elapsed since initClock() was last called.
Returns:
Elapsed milliseconds
initClock
()
Resets the clock
setPeriodMS
-
ms
Sets the period in milliseconds
Parameters:
-
ms
NumberPeriod in milliseconds
enable
-
enable
Enables the PWM output for a motor
Parameters:
-
enable
BooleanEnables the PWM output if true, disables if false
setSpeed
-
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.
Parameters:
-
speed
NumberSpeed to set the motor to
setDirection
-
dir
Sets the direction of the motor, clockwise or counterclockwise
Parameters:
-
dir
L298_DIRECTION_TDirection to set the motor to
stepperSteps
-
steps
Steps the stepper motor a specified number of steps
Parameters:
-
steps
NumberNumber of steps to move the stepper motor