วันศุกร์ที่ 24 สิงหาคม พ.ศ. 2550

โคดสอบ

' {$PBASIC 2.5}
' {$PORT COM2}
' {$STAMP BS2sx}
a VAR Word
b VAR Word
c VAR Word
d VAR Word
PAUSE 2000
a = 0
b = 0
c = 0
d = 0
GOSUB forward : PAUSE 1177
GOSUB S_left : PAUSE 205
DO
a = a + 1
GOSUB T_RIGHT : PAUSE 20
GOSUB FORWARD : PAUSE 15
LOOP UNTIL ( a = 75 )
DO
b = b + 1
GOSUB T_Left : PAUSE 21
GOSUB FORWARD : PAUSE 15
LOOP UNTIL ( b = 90 )
DOc = c + 1
GOSUB T_RIGHT : PAUSE 20
GOSUB FORWARD : PAUSE 15
LOOP UNTIL ( c = 80 )
GOSUB forward : PAUSE 2344
DOd = d + 1
GOSUB T_Right : PAUSE 20
GOSUB forward : PAUSE 5
LOOP UNTIL ( d = 50 )
GOSUB forward : PAUSE 4288
GOSUB S_RIGHT : PAUSE 370
GOSUB motor_off : PAUSE 3000
forward: HIGH 13 : LOW 12 : HIGH 15 : LOW 14 :RETURN
backward: HIGH 12 : LOW 13 : HIGH 14 : LOW 15 :RETURN
S_right: HIGH 13 : LOW 12 : HIGH 14 : LOW 15 :RETURN
S_left: HIGH 12 : LOW 13 : HIGH 15 : LOW 14 : RETURN
T_left: LOW 13 : LOW 12 : HIGH 15 : LOW 14 : RETURN
T_right: HIGH 13 : LOW 12 : LOW 15 : LOW 14 : RETURN
Motor_off:LOW 13 : LOW 12 : LOW 15 : LOW 14 : RETURN

ไม่มีความคิดเห็น: