1.
The controller can take up to 2 motors. Plug one motor into the terminal labelled OUT1 and OUT2. Plug the second motor into the terminal labelled OUT3 and OUT4:
2.
The row of pins on the bottom right of the L298N control the speed and direction of the motors. IN1 and IN2 control the direction of the motor connected to OUT1 and OUT2. IN3 and IN4 control the direction of the motor connected to OUT3 and OUT4. Here I plugged them into pins 6, 9, 10, and 11 on the Arduino.
Pin6------In4
Pin9------In3
Pin10----In2
Pin11----In1
}
}
MOTOR A
MOTOR B
3.
You can power the L298N with up to 12V by plugging your power source into the pin on the L298N labelled "12V". The pin labelled "5V" is a 5V output that you can use to power your Arduino. Here are some ways to wire it depending on your use case:
a.
Wire this way if you are going to power the Arduino off of the battery that the L298 module is connected to.
b.
Wire this way if you are going to power the Arduino off of its own power source.
4.
Software:
Setting IN1 to 255, and IN2 to 0, will cause the left motor to turn a direction.
Setting IN1 to 0, and IN2 to 255, will cause the left motor to spin the other direction. The same applies to IN3 and IN4.
Speed:
You can change the speed by choosing a number 0-255, anywhere 255, is located in the code.