Robofun 機器人論壇

 找回密碼
 申請會員
搜索
熱搜: 活動 交友 discuz
查看: 5896|回復: 1

+Easy Bluetooth 藍芽模組的問題

[複製鏈接]
發表於 2012-11-23 20:34:40 | 顯示全部樓層 |閱讀模式
本帖最後由 a50292 於 2012-11-24 12:09 編輯

' {$STAMP BS2}
' {$PBASIC 2.5}

Ping            PIN     15
PingServo       PIN     14
LeftServo      PIN     13
RightServo      PIN     12
xx      PIN     11

BT_RX PIN 2
BT_TX PIN 0

BT_SPEED CON 84

tLeft VAR Word
tRight VAR Word
temp VAR Word

rawDist         VAR     Word
sweepcount      VAR     Word

x               VAR     Byte
pulseCount      VAR     Byte

counter VAR Word
inDistance VAR Word

Main:
FOR sweepcount = 350 TO 1150 STEP 100
  FOR x = 0 TO 5
    PULSOUT 15, sweepcount
    PAUSE 10
  NEXT
  GOSUB GetSonar
NEXT

FOR sweepcount = 950 TO 550 STEP 100
  FOR x = 0 TO 5
    PULSOUT 15, sweepcount
    PAUSE 10
  NEXT
  GOSUB GetSonar
NEXT
GOTO Main

GetSonar:

LOW 15
PULSOUT 15, 5
PULSIN 15, 1, rawDist

  IF (rawDist < 600) THEN
    IF (sweepcount < 750) THEN
      GOSUB Turn_Left
    ELSEIF (sweepcount > 750) THEN
      GOSUB Turn_Right
    ELSE
      GOSUB Back_Up
    ENDIF
  ELSE
    GOSUB Forward_Pulse
  ENDIF

RETURN



Forward_Pulse:
FOR pulsecount = 0 TO 5

HIGH 14
LOW 13
LOW 11
HIGH 12

PAUSE 20
NEXT
RETURN

Turn_Left:
FOR pulseCount = 0 TO 10


LOW 13
HIGH 14


PAUSE 20
NEXT
RETURN

Turn_Right:

FOR pulseCount = 0 TO 10

LOW 12
HIGH 11

PAUSE 20
NEXT
RETURN

Back_Up:
FOR pulseCount = 0 TO 3

HIGH 13
LOW 14
LOW 11
HIGH 12



PAUSE 10
NEXT


FOR pulseCount = 0 TO 7

HIGH 13
LOW 14
LOW 11
HIGH 12


PAUSE 10
NEXT
RETURN



--------------

這是我還沒加上之前的 因為是要控制直流馬達跟感測器 所以用這樣寫 (1是往前 2是往後 不用左右)
不過加上藍芽的程式我摸不出來 希望能幫忙一下
playrobot 該用戶已被刪除
發表於 2013-1-14 17:01:59 | 顯示全部樓層
抱歉, 您已經解決了嗎 ?

Easy Bluetooth Documentation v1.3 (.pdf)
RBT-001 Module - User Manual (.pdf)
Easy Bluetooth Software (.zip)
Easy Bluetooth Education Sample Code (.zip)
Easy Bluetooth Cell Phone Applet (.zip)
Easy Bluetooth Code For GUI (.bs2)
Easy Bluetooth AppNote (Bluetooth to Bluetooth Connection) (.pdf)
Easy Bluetoothx2demo (.zip)
您需要登錄後才可以回帖 登錄 | 申請會員

本版積分規則

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

GMT+8, 2024-3-29 15:04 , Processed in 0.217370 second(s), 8 queries , Apc On.

Powered by Discuz! X3.2

© 2001-2013 Comsenz Inc.

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