Library for controlling L298N Motor Controller based on the Adafruit Motor Shield Library, includes classes and two functions.
L298N_Motor myMotor(uint8_t pinA, uint8_t pinB, uint8_t pinEn);
L298N_Motor myMotor(2, 3, A0);
uint8_t pinA
: Output pin #1 for the motor.uint8_t pinB
: Output pin #2 for the motor.uint8_t pinEn
: Enable pin for the motor (-1
if enable is not used).
- Using keywords:
myMotor.run(FORWARD); //2
myMotor.run(RELEASE); //1
myMotor.run(BACKWARD); //0
- Using integer values:
myMotor.run(0); // BACKWARD
myMotor.run(1); // RELEASE
myMotor.run(2); // FORWARD
myMotor.run(FORWARD); // Motor will run {PinA: HIGH, PinB: LOW}
uint8_t motorState
: Controls motor direction with the following values:0
(orBACKWARD
):{PinA: LOW, PinB: HIGH}
1
(orRELEASE
):{PinA: LOW, PinB: LOW}
2
(orFORWARD
):{PinA: HIGH, PinB: LOW}
myMotor.setSpeed(uint8_t speed);
myMotor.setSpeed(255);
uint8_t speed
: Speed value between0
and255
(for PWM control).