Raspberry Pi - L298N Module Drives DC Motor

MCU or Raspberry Pi generally use L298n module to drive the motor. The physical map of L298N is as follows.


Note:
1. 5v power supply can not be used
2. When writing code on the same side, it must be one high and one low. If it is the same, it will not be able to go. I encounter this problem every time here, write it down and

put the DC power supply of L289N After connecting, connect the GND of the Raspberry Pi and the GND of the L298N together, because the L298N can identify whether the IN1 and IN2 sent by the Raspberry Pi are high or low after the common ground.   

The 2, 3 and 4 pins of the Raspberry Pi are connected to A Enable, IN1 and IN2 respectively. (Remove the shorting cap)

It can be seen from the control table that if pin 2 is high level, pin 3 is high level, and pin 4 is low level, the motor will rotate forward.

Write a program:

the wiring remains the same! This program can make motor A rotate forward at different speeds.

After running the program in the Raspberry Pi, you can see that the speed of the motor changes with the change of the duty cycle.

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=326069463&siteId=291194637