Robofun 機器人論壇
標題:
紅外線感應程式
[打印本頁]
作者:
s9527s
時間:
2010-5-11 07:23
標題:
紅外線感應程式
有人可以教我紅外線程式要怎麼寫嗎?
我用的程式是BASI Boe-Bot
以下是我寫的程式~可是把程式寫到車子上 車子會不停的在原地右轉
有人可以教我一下嗎?
' Robotics with the Boe-Bot - FastIrRoaming.bs2
' Higher performance IR object detection assisted navigation
' {$STAMP BS2}
' {$PBASIC 2.5}
DEBUG "Program Running!"
irDetectLeft VAR Bit ' Variable Declarations
irDetectRight VAR Bit
irDetectL1 VAR Bit
irDetectR1 VAR Bit
irDetectCentral VAR Bit
pulseLeft VAR Word
pulseRight VAR Word
pulseL1 VAR Word
pulseR2 VAR Word
FREQOUT 4, 2000, 3000 ' Signal program start/reset.
DO ' Main Routine
FREQOUT 14, 1, 4000 ' Check IR Detectors
irDetectLeft = IN15
FREQOUT 2, 1, 4000
irDetectRight = IN0
FREQOUT 8, 1, 5000
irDetectCentral = IN9
FREQOUT 3, 1, 20000
irDetectR1 = IN4
FREQOUT 11 ,1, 20000
irDetectL1 = IN12
' Decide how to navigate.
IF (irDetectLeft = 0) THEN
pulseLeft = 850
pulseRight = 825
ELSEIF (irDetectRight = 0) THEN
pulseLeft = 625
pulseRight = 650
ELSEIF (irDetectCentral = 0)AND(irDetectR1 = 1)THEN
pulseLeft = 650
pulseRight = 650
ELSEIF (irDetectCentral = 0)AND(irDetectL1 = 1)THEN
pulseLeft = 850
pulseRight = 850
ELSE
pulseLeft = 850
pulseRight = 650
ENDIF
PULSOUT 13,pulseLeft ' Apply the pulse.
PULSOUT 12,pulseRight
PAUSE 15
LOOP ' Repeat main routine
歡迎光臨 Robofun 機器人論壇 (https://robofun.net/forum/)
Powered by Discuz! X3.2