program to pick from a menu
ouconvert
Posts: 17
alright, what i want the stamp to do is prompt the user for one position out of ten, A-J (horizontal movement). And than asks for another position,
0-9 (vertical movement). A-J and 0-1 are constants relating to a position that a stepper motor will go to. im experimenting with a servo motor
right now and im not having much luck. im not using the commands to command a·stepper with the servo so thats not the problem. ·is there a switch function like in C? any input would be great. thanks
sean
0-9 (vertical movement). A-J and 0-1 are constants relating to a position that a stepper motor will go to. im experimenting with a servo motor
right now and im not having much luck. im not using the commands to command a·stepper with the servo so thats not the problem. ·is there a switch function like in C? any input would be great. thanks
sean
Comments
' {$STAMP BS2}
' {$PBASIC 2.5}
counter VAR Word
pulses VAR Bit
duration VAR Bit
a CON 500
k CON 1000
DO
DEBUG CLS, "Enter selection of vertical movement, a-j.", CR
DEBUGIN HEX pulses
IF pulses = a THEN
FOR counter = 1 TO a
PULSOUT 14, k
PAUSE 20
NEXT
DEBUG "Done"
PAUSE 1000
ENDIF
LOOP
One of the problems is that the variables that you have defined as BIT need to be defined as BYTE or WORD variables depending on the values they will contain.
/code
BIT =·· 0 or 1 ONLY
BYTE = 0·· ->··· 255
WORD = 0 -> 65535
/code
Regards,
Bruce Bates
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Jon Williams
Applications Engineer, Parallax
' {$STAMP BS2}
' {$PBASIC 2.5}
counter VAR Word
horizontal VAR Byte
vertical VAR Byte
a CON 150
b CON 150
c CON 150
k CON 1000
l CON 500
m CON 750
DO
DEBUG CLS, "Enter selection of vertical movement, a-j.", CR
DEBUGIN HEX vertical
DEBUG "Program running.", CR
IF vertical = a THEN GOSUB case_0
IF vertical = b THEN GOSUB case_1
IF vertical = c THEN GOSUB case_2
case_0:
FOR counter = 1 TO 150
PULSOUT 14, 1000
DEBUG "Going to 10 o'clock.", CR
PAUSE 20
NEXT
GOTO finishup
case_1:
FOR counter = 1 TO 150
PULSOUT 14, 150
DEBUG "Going to 2 o'clock.", CR
PAUSE 20
NEXT
GOTO finishup
case_2:
FOR counter = 1 TO 150
PULSOUT 14, 750
DEBUG "Going to 12 o'clock.", CR
PAUSE 20
NEXT
GOTO finishup
finishup:
DEBUG "Done."
PAUSE 500
LOOP
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Jon Williams
Applications Engineer, Parallax