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:
-
pwmNumberDigital pin to use for a DC motor - must be PWM-capable
-
dir1NumberDigital pin to use for motor direction pin 1
-
dir2NumberDigital 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:
-
stepsPerRevNumberNumber of steps per full revolution
-
enNumberEnables the pin
-
i1NumberDigital pin to use for stepper input 1
-
i2NumberDigital pin to use for stepper input 2
-
i3NumberDigital pin to use for stepper input 3
-
i4NumberDigital 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:
-
msNumberPeriod in milliseconds
enable
-
enable
Enables the PWM output for a motor
Parameters:
-
enableBooleanEnables 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:
-
speedNumberSpeed to set the motor to
setDirection
-
dir
Sets the direction of the motor, clockwise or counterclockwise
Parameters:
-
dirL298_DIRECTION_TDirection to set the motor to
stepperSteps
-
steps
Steps the stepper motor a specified number of steps
Parameters:
-
stepsNumberNumber of steps to move the stepper motor