by Gman » Fri Jun 30, 2006 2:09 pm
by Gman
Fri Jun 30, 2006 2:09 pm
Hi all
I thought I'd register and share my code for choosing how many steps Robonova takes, and looping the default walk.
I'm certainly no expert but BASIC is fairly basic after all. Maybe this can help people who are just learning to program.
for/next and if/then are your friends, get to know them if you don't already.
the following is the first changes I've made to the overall template program.
1) First declare these variables with the rest so they can be used
DIM C10 AS BYTE 'counts how many sets of steps
DIM steps AS BYTE 'used in for/next loop with C10
C10 = 1 'set default value at 1 set of steps
2) assign a key to act as the counter input like this
'================================================
k32: ' F
TEMPO 230
MUSIC "D"
C10 = C10 + 1 'add another set of steps C10 default is 1 set of steps
IF C10 > 10 THEN 'If button pressed more than 9 times
TEMPO 230 'Makes a different beep and resets C10 to 1
MUSIC "O1 D" 'So your robot won't run away too far.be carefull near edges!!
C10 = 1
ENDIF
GOTO main_exit
'================================================
3) change forward_walk: to loop the main part like this
'================================================
forward_walk:
SPEED 5
MOVE24 85, 71, 152, 91, 112, 60, 100, 40, 80, , , , 100, 40, 80, , , , 112, 76, 145, 93, 92, 60,
SPEED 14
'left up
MOVE24 90, 107, 105, 105, 114, 60, 90, 40, 80, , , , 100, 40, 80, , , , 114, 76, 145, 93, 90, 60,
'---------------------------------------
FOR steps = 1 TO C10 'loops main part of walk according to value of C10
'---------------------------------------
'left down
MOVE24 90, 56, 143, 122, 114, 60, 80, 40, 80, , , , 105, 40, 80, , , , 113, 80, 145, 90, 90, 60,
MOVE24 90, 46, 163, 112, 114, 60, 80, 40, 80, , , , 105, 40, 80, , , , 112, 80, 145, 90, 90, 60,
SPEED 10
'left center
MOVE24 100, 66, 141, 113, 100, 100, 90, 40, 80, , , , 100, 40, 80, , , , 100, 83, 156, 80, 100, 100,
MOVE24 113, 78, 142, 105, 90, 60, 100, 40, 80, , , , 100, 40, 80, , , , 90, 102, 136, 85, 114, 60,
SPEED 14
'right up
MOVE24 113, 76, 145, 93, 90, 60, 100, 40, 80, , , , 90, 40, 80, , , , 90, 107, 105, 105, 114, 60,
'right down
MOVE24 113, 80, 145, 90, 90, 60, 105, 40, 80, , , , 80, 40, 80, , , , 90, 56, 143, 122, 114, 60,
MOVE24 112, 80, 145, 90, 90, 60, 105, 40, 80, , , , 80, 40, 80, , , , 90, 46, 163, 112, 114, 60,
SPEED 10
'right center
MOVE24 100, 83, 156, 80, 100, 100, 100, 40, 80, , , , 90, 40, 80, , , , 100, 66, 141, 113, 100, 100,
MOVE24 90, 102, 136, 85, 114, 60, 100, 40, 80, , , , 100, 40, 80, , , , 113, 78, 142, 105, 90, 60,
SPEED 14
'left up
MOVE24 90, 107, 105, 105, 114, 60, 90, 40, 80, , , , 100, 40, 80, , , , 113, 76, 145, 93, 90, 60,
'---------------------------------------
NEXT steps 'end of loop
'---------------------------------------
SPEED 5
MOVE24 85, 71, 152, 91, 112, 60, 100, 40, 80, , , , 100, 40, 80, , , , 112, 76, 145, 93, 92, 60,
C10 = 1 'reset to default value 1 set of steps
RETURN
'================================================
this can also be applied to backward_walk: and fast_walk: by looping the appropriate part of the routine.
NOTE: if you apply these changes to fast_walk:
you can delete the local declaration
DIM A10 as BYTE as A10 will no longer be used.
reuse the variables C10 and steps for each walking routine.
have fun and always save a working copy of your program before making changes.
Hi all
I thought I'd register and share my code for choosing how many steps Robonova takes, and looping the default walk.
I'm certainly no expert but BASIC is fairly basic after all. Maybe this can help people who are just learning to program.
for/next and if/then are your friends, get to know them if you don't already.
the following is the first changes I've made to the overall template program.
1) First declare these variables with the rest so they can be used
DIM C10 AS BYTE 'counts how many sets of steps
DIM steps AS BYTE 'used in for/next loop with C10
C10 = 1 'set default value at 1 set of steps
2) assign a key to act as the counter input like this
'================================================
k32: ' F
TEMPO 230
MUSIC "D"
C10 = C10 + 1 'add another set of steps C10 default is 1 set of steps
IF C10 > 10 THEN 'If button pressed more than 9 times
TEMPO 230 'Makes a different beep and resets C10 to 1
MUSIC "O1 D" 'So your robot won't run away too far.be carefull near edges!!
C10 = 1
ENDIF
GOTO main_exit
'================================================
3) change forward_walk: to loop the main part like this
'================================================
forward_walk:
SPEED 5
MOVE24 85, 71, 152, 91, 112, 60, 100, 40, 80, , , , 100, 40, 80, , , , 112, 76, 145, 93, 92, 60,
SPEED 14
'left up
MOVE24 90, 107, 105, 105, 114, 60, 90, 40, 80, , , , 100, 40, 80, , , , 114, 76, 145, 93, 90, 60,
'---------------------------------------
FOR steps = 1 TO C10 'loops main part of walk according to value of C10
'---------------------------------------
'left down
MOVE24 90, 56, 143, 122, 114, 60, 80, 40, 80, , , , 105, 40, 80, , , , 113, 80, 145, 90, 90, 60,
MOVE24 90, 46, 163, 112, 114, 60, 80, 40, 80, , , , 105, 40, 80, , , , 112, 80, 145, 90, 90, 60,
SPEED 10
'left center
MOVE24 100, 66, 141, 113, 100, 100, 90, 40, 80, , , , 100, 40, 80, , , , 100, 83, 156, 80, 100, 100,
MOVE24 113, 78, 142, 105, 90, 60, 100, 40, 80, , , , 100, 40, 80, , , , 90, 102, 136, 85, 114, 60,
SPEED 14
'right up
MOVE24 113, 76, 145, 93, 90, 60, 100, 40, 80, , , , 90, 40, 80, , , , 90, 107, 105, 105, 114, 60,
'right down
MOVE24 113, 80, 145, 90, 90, 60, 105, 40, 80, , , , 80, 40, 80, , , , 90, 56, 143, 122, 114, 60,
MOVE24 112, 80, 145, 90, 90, 60, 105, 40, 80, , , , 80, 40, 80, , , , 90, 46, 163, 112, 114, 60,
SPEED 10
'right center
MOVE24 100, 83, 156, 80, 100, 100, 100, 40, 80, , , , 90, 40, 80, , , , 100, 66, 141, 113, 100, 100,
MOVE24 90, 102, 136, 85, 114, 60, 100, 40, 80, , , , 100, 40, 80, , , , 113, 78, 142, 105, 90, 60,
SPEED 14
'left up
MOVE24 90, 107, 105, 105, 114, 60, 90, 40, 80, , , , 100, 40, 80, , , , 113, 76, 145, 93, 90, 60,
'---------------------------------------
NEXT steps 'end of loop
'---------------------------------------
SPEED 5
MOVE24 85, 71, 152, 91, 112, 60, 100, 40, 80, , , , 100, 40, 80, , , , 112, 76, 145, 93, 92, 60,
C10 = 1 'reset to default value 1 set of steps
RETURN
'================================================
this can also be applied to backward_walk: and fast_walk: by looping the appropriate part of the routine.
NOTE: if you apply these changes to fast_walk:
you can delete the local declaration
DIM A10 as BYTE as A10 will no longer be used.
reuse the variables C10 and steps for each walking routine.
have fun and always save a working copy of your program before making changes.
Last edited by Gman on Fri Jun 30, 2006 3:26 pm, edited 1 time in total.