這篇文章主要介紹了Raspberry PI+L298N怎么用,具有一定借鑒價(jià)值,感興趣的朋友可以參考下,希望大家閱讀完這篇文章之后大有收獲,下面讓小編帶著大家一起了解一下。
十載的徐州網(wǎng)站建設(shè)經(jīng)驗(yàn),針對(duì)設(shè)計(jì)、前端、開發(fā)、售后、文案、推廣等六對(duì)一服務(wù),響應(yīng)快,48小時(shí)及時(shí)工作處理。營(yíng)銷型網(wǎng)站建設(shè)的優(yōu)勢(shì)是能夠根據(jù)用戶設(shè)備顯示端的尺寸不同,自動(dòng)調(diào)整徐州建站的顯示方式,使網(wǎng)站能夠適用不同顯示終端,在瀏覽器中調(diào)整網(wǎng)站的寬度,無論在任何一種瀏覽器上瀏覽網(wǎng)站,都能展現(xiàn)優(yōu)雅布局與設(shè)計(jì),從而大程度地提升瀏覽體驗(yàn)。創(chuàng)新互聯(lián)建站從事“徐州網(wǎng)站設(shè)計(jì)”,“徐州網(wǎng)站推廣”以來,每個(gè)客戶項(xiàng)目都認(rèn)真落實(shí)執(zhí)行。
L298N 是一種雙H橋電機(jī)驅(qū)動(dòng)芯片,可以通過樹莓派的GPIO的高低電平來控制L298N的行為。
L298N:
root@raspberrypi:~# gpio readall +-----+-----+---------+------+---+-Model B2-+---+------+---------+-----+-----+ | 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 B2-+---+------+---------+-----+-----+
12V:12V輸入正極
GND:電源地,接電源負(fù)極
5V:5V輸入,暫時(shí)不太明白這個(gè)的作用
ENA:A通道使能
IN1:A通道邏輯輸入1
IN2:A通道邏輯輸入2
OUT1: A通道輸出
OUT2: A通道輸出
ENB:B通道使能
IN3:B通道邏輯輸入1
IN4:B通道邏輯輸入2
OUT3: B通道輸出
OUT4: B通道輸出
樹莓派和L298N的接線:
GPIO.0 -- IN1
GPIO.1 -- IN2
GPIO.4 -- ENA
L298N 輸入12v供電 OUT1,OUT2接馬達(dá)
代碼如下:
import RPi.GPIO as GPIO import time GPIO.setmode(GPIO.BOARD) INTA = 16 INT1 = 11 INT2 = 12 GPIO.setup(INTA,GPIO.OUT) GPIO.setup(INT1,GPIO.OUT) GPIO.setup(INT2,GPIO.OUT) # 使能信號(hào) GPIO.output(INTA,GPIO.HIGH) # 控制轉(zhuǎn)動(dòng)方向及制動(dòng),參考上圖表格 GPIO.output(INT2,GPIO.HIGH) GPIO.output(INT1,GPIO.LOW) time.sleep(10) GPIO.cleanup()
感謝你能夠認(rèn)真閱讀完這篇文章,希望小編分享的“Raspberry PI+L298N怎么用”這篇文章對(duì)大家有幫助,同時(shí)也希望大家多多支持創(chuàng)新互聯(lián),關(guān)注創(chuàng)新互聯(lián)行業(yè)資訊頻道,更多相關(guān)知識(shí)等著你來學(xué)習(xí)!