In addition to Weibo, there is also WeChat
Please pay attention

WeChat public account
Shulou
2025-11-05 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Internet Technology >
Share
Shulou(Shulou.com)06/01 Report--
This article mainly introduces how to use Raspberry PI+L298N, has a certain reference value, interested friends can refer to, I hope you can learn a lot after reading this article, the following let the editor take you to understand it.
Brief introduction
L298N is a double H-bridge motor driver chip, which can control the behavior of L298N through the high and low GPIO level of raspberry pie.
L298N:
Root@raspberrypi:~# gpio readall +-+-Model B2 pin of raspberry pie | BCM | wPi | Name | Mode | V | Physical | V | Mode | Name | wPi | BCM | +-+ -+-3.3v | | 1 | 2 | | 5v | 2 | 8 | SDA.1 | IN | 1 | 3 | | 4 | | 5V | 3 | 9 | SCL.1 | IN | 1 | 5 | | 6 | | 0v | 4 | 7 | GPIO. 7 | IN | 1 | 7 | 8 | 1 | ALT0 | TxD | 15 | 14 | 0v | | 9 | 10 | 1 | ALT0 | RxD | 16 | 15 | 17 | 0 | GPIO. 0 | IN | 0 | 11 | | 12 | 0 | IN | GPIO. 1 | 1 | 18 | | 27 | 2 | GPIO. 2 | IN | 0 | 13 | | 14 | | 0v | 22 | 3 | GPIO. 3 | IN | 0 | 15 | | 16 | 1 | IN | GPIO. 4 | 4 | 23 | 3.3v | | 17 | 18 | 0 | IN | GPIO. 5 | 5 | 24 | | 10 | 12 | MOSI | IN | 0 | 19 | | 20 | | 0v | 9 | 13 | MISO | IN | 0 | 21 | | 22 | 0 | IN | GPIO. 6 | 6 | 25 | | 11 | 14 | SCLK | IN | 0 | 23 | 24 | 1 | IN | CE0 | 10 | 8 | 0v | | 25 | 26 | 1 | IN | CE1 | 11 | 7 | +-- + -+ | 28 | 17 | GPIO.17 | IN | 0 | 51 | | 52 | 0 | IN | GPIO.18 | 18 | 29 | 30 | 19 | GPIO.19 | IN | 0 | 53 | | 54 | 0 | IN | GPIO.20 | 20 | 31 | +- +-- +-+ | BCM | wPi | Name | Mode | V | Physical | V | Mode | Name | wPi | BCM | +-- +-Model B2Musashi -+ L298N interface
12V:12V input positive pole
GND: power source, connect the negative pole of the power supply
5V:5V input, I don't understand the function of this at the moment.
ENA:A channel enable
IN1:A channel logic input 1
IN2:A channel logic input 2
OUT1: a channel output
OUT2: a channel output
ENB:B channel enable
IN3:B channel logic input 1
IN4:B channel logic input 2
OUT3: B channel output
OUT4: B channel output
Wiring
Connection of raspberry pie and L298N:
GPIO.0-IN1
GPIO.1-IN2
GPIO.4-ENA
L298N input 12v power supply OUT1,OUT2 connection motor
Code testing
The code is as follows:
Import RPi.GPIO as GPIOimport timeGPIO.setmode (GPIO.BOARD) INTA = 16INT1 = 11INT2 = 12GPIO.setup (INTA,GPIO.OUT) GPIO.setup (INT1,GPIO.OUT) GPIO.setup (INT2,GPIO.OUT) # enable signal GPIO.output (INTA,GPIO.HIGH) # Control rotation direction and braking, refer to the table GPIO.output (INT2,GPIO.HIGH) GPIO.output (INT1,GPIO.LOW) time.sleep (10) GPIO.cleanup () above. Thank you for reading this article carefully. I hope the article "how to use Raspberry PI+L298N" shared by the editor will be helpful to everyone. At the same time, I also hope that you will support and pay attention to the industry information channel. More related knowledge is waiting for you to learn!
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

The market share of Chrome browser on the desktop has exceeded 70%, and users are complaining about
The world's first 2nm mobile chip: Samsung Exynos 2600 is ready for mass production.According to a r
A US federal judge has ruled that Google can keep its Chrome browser, but it will be prohibited from
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope





About us Contact us Product review car news thenatureplanet
More Form oMedia: AutoTimes. Bestcoffee. SL News. Jarebook. Coffee Hunters. Sundaily. Modezone. NNB. Coffee. Game News. FrontStreet. GGAMEN
© 2024 shulou.com SLNews company. All rights reserved.