a50292 發表於 2012-11-23 20:34:40

+Easy Bluetooth 藍芽模組的問題

本帖最後由 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)
頁: [1]
查看完整版本: +Easy Bluetooth 藍芽模組的問題