turn program
irkris77
Posts: 10
need a program to turn a servo motor using a hb25 and basic stamp to turn and go straing
Comments
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
- Stephen
·· Can you post the program that you sent me on the forums? Are you using 1 or 2 HB25 modules?
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Respectfully,
Joshua Donelson
www.parallax.com
'
[noparse][[/noparse] Variables ]
result VAR Word
true CON 1
false CON 0
index VAR Word ' Counter For Ramping
counter VAR Word
DO : LOOP UNTIL HB25 = 1 ' Wait For HB-25 Power Up
LOW HB25 ' Make I/O Pin Output/Low
PAUSE 6 ' Wait For HB-25 To Initialize
PULSOUT HB25, 750 ' Stop Motor 1
PAUSE 1 ' 1 mS Delay
PULSOUT HB25, 750
Main:
DO
GOSUB POT_READING
DEBUG DEC result, LF
'ruleFired = false
Rule1:
IF (result < 2112) THEN'AND (ruleFired = false) THEN
PULSOUT 12, 650
GOSUB RIGHT
'ruleFired = True
DEBUG "rule 1 ",CR,LF
ENDIF
PAUSE 200
'Rule2:
' IF (result > 2112) THEN'AND (ruleFired = false) THEN
' GOSUB Rightcenter
'ruleFired = True
' DEBUG "rule 2 ", CR, LF
' ENDIF
' PAUSE 200
Rule3:
IF (result > 2112) THEN'AND (ruleFired = false) THEN
PULSOUT 12, 650
GOSUB left
'ruleFired = True
DEBUG "rule 3 ", CR, LF
ENDIF
LOOP
'SUB POT READING'''''''''''''''''''''
POT_READING:
HIGH 7
PAUSE 200
RCTIME 7,1,RESULT
DEBUG ? RESULT
'GOTO POT_READIN
RETURN
'SUB TURNE RIGHT
Right:
FOR counter = 1 TO 100
PULSOUT 14, 650
PAUSE 20
NEXT
GOTO MAIN
Left:
FOR counter = 1 TO 100
PULSOUT 14, 850
PAUSE 2
NEXT
GOTO Main
forward:
DO
PULSOUT 12, 650
PAUSE 20
LOOP
END
Rightcenter:
FOR counter = 1 TO 100
PULSOUT 14, 760
PAUSE 2
NEXT