Robofun 機器人論壇

 找回密碼
 申請會員
搜索
熱搜: 活動 交友 discuz
查看: 3791|回復: 0
打印 上一主題 下一主題

紅外線感應程式

[複製鏈接]
跳轉到指定樓層
1#
發表於 2010-5-11 07:23:21 | 只看該作者 回帖獎勵 |倒序瀏覽 |閱讀模式
有人可以教我紅外線程式要怎麼寫嗎?
我用的程式是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
您需要登錄後才可以回帖 登錄 | 申請會員

本版積分規則

小黑屋|手機版|Archiver|機器人論壇 from 2005.07

GMT+8, 2024-4-29 22:42 , Processed in 0.191883 second(s), 7 queries , Apc On.

Powered by Discuz! X3.2

© 2001-2013 Comsenz Inc.

快速回復 返回頂部 返回列表