-
Notifications
You must be signed in to change notification settings - Fork 5
Software
Download the ZIP file with the library. The link is located in Current Version table at the top of wiki main page.
In the Arduino IDE, navigate to Sketch > Include Library. At the top of the drop down list, select the option to Add .ZIP Library. You will be prompted to select the library you would like to add. Navigate to the .zip file's location and open it.
Return to the Sketch > Import Library menu. You should now see the library at the bottom of the drop-down menu. It is ready to be used in your sketch. The zip file will have been expanded in the libraries folder in your Arduino sketches directory. The Library will be available to use in sketches, but examples for the library will not be exposed in the File > Examples until after the IDE has restarted.
Source: Arduino Guides
L298N driver(ena, in1, in2, in3, in4, enb [, invert][, minspeed]);
ena - Enable/Disable and regulates MOTOR_A speed (must be a PWM pin).
in1/2 - Controls MOTOR_A.
in3/4 - Controls MOTOR_B.
enb - Enable/Disable and regulates MOTOR_B speed (must be a PWM pin).
invert - [Optional] Change direction solution (left<->right).
minspeed - [Optional] Minimum speed motors can handle before stop.
driver.stop([brake][, delay_time]) - Stop vehicle (using brakes if true) and waits delay_time.
driver.forward([speed][, delay_time]) - Move forward and waits delay_time.
driver.backward([speed][, delay_time]) - Move backward and waits delay_time.
driver.left([speed][, delay_time]) - Rotate left and waits delay_time.
driver.right([speed][, delay_time]) - Rotate right and waits delay_time.
driver.drive([direction][, speed][, slave_percent][, delay_time])
Send an order to motors. If no direction given, go strait ahead. slave_percent (0-100) works only on FORWARD_L, FORWARD_R, BACKWARD_L and BACKWARD_R. It defines the slave motor speed. If speed is 150 and slave_percent is 50, then slave_speed is 75 (150*50/100).
For an example source code see here.
Exchange motor wires A<->B (hardware method) or set invert true when create the object (software method).
Remember to use PWM pins for ENA/ENB: 3, 5-6, 9-11 on most Arduino boards; 2-13 and 44-46 on Arduino Mega.