資源簡介
本人在2018年11月24-25日的廣東省工科技能綜合實驗大賽中獲得了二等獎,實際上因為硬件的問題和場地的問題,我們應該獲得更高的獎項的。這是所有源碼,python的,使用openmvIDE編輯。

代碼片段和文件信息
from?pyb?import?Pin?Timer
inverse_left=False??#change?it?to?True?to?inverse?left?wheel
inverse_right=False?#change?it?to?True?to?inverse?right?wheel
ain1?=??Pin(‘P0‘?Pin.OUT_PP)
ain2?=??Pin(‘P1‘?Pin.OUT_PP)
bin1?=??Pin(‘P2‘?Pin.OUT_PP)
bin2?=??Pin(‘P3‘?Pin.OUT_PP)
ain1.low()
ain2.low()
bin1.low()
bin2.low()
pwma?=?Pin(‘P7‘)
pwmb?=?Pin(‘P8‘)
tim?=?Timer(4?freq=1000)
ch1?=?tim.channel(1?Timer.PWM?pin=pwma)
ch2?=?tim.channel(2?Timer.PWM?pin=pwmb)
ch1.pulse_width_percent(0)
ch2.pulse_width_percent(0)
def?run(left_speed?right_speed):
????if?inverse_left==True:
????????left_speed=(-left_speed)
????if?inverse_right==True:
????????right_speed=(-right_speed)
????if?left_speed?0:
????????ain1.low()
????????ain2.high()
????else:
????????ain1.high()
????????ain2.low()
????ch1.pulse_width_percent(abs(left_speed))
????if?right_speed?0:
????????bin1.low()
????????bin2.high()
????else:
????????bin1.high()
????????bin2.low()
????ch2.pulse_width_percent(abs(right_speed))
?屬性????????????大小?????日期????時間???名稱
-----------?---------??----------?-----??----
?????目錄???????????0??2018-11-25?08:52??4pid和普通的結合\
?????文件????????1034??2018-11-25?00:43??4pid和普通的結合\car.py
?????文件????????6732??2018-11-25?03:00??4pid和普通的結合\hand.py
?????文件????????8962??2018-11-25?08:26??4pid和普通的結合\main.py
?????文件????????2744??2018-11-21?18:43??4pid和普通的結合\move.py
評論
共有 條評論