imix500
09-03-2008, 06:53 PM
Hello all, I'm new to this forum and micro controllers but not electronics.
So I'm having trouble with the code for this project. It needs to spin a motor with a paddle wheel attached a certain number of times and then stop for a certain amount of time. The external components (motor ,paddle wheel switch) are working fine. Since the BS1 can't count, I'm using the FOR...NEXT instruction to set a number of loops for both paddle counting and interval timing. I am planning on using FOR...NEXT a large number of times for some of the intervals (~6 to 12 hours). Is there a better way in the BS1? Right now it seems like the BUTTON instruction is resetting the FOR...NEXT instruction for the motor control. Here's the program: Thanks!
SYMBOL btn = 0 ' FOR BUTTON
SYMBOL btnWrk = B4
SYMBOL reps = B2 ' FOR...NEXT loop counter
motor:
HIGH 0
FOR reps = 1 TO 3 ' repeat for 3 button pushes
BUTTON Btn, 7, 1, 255, btnWrk, 0, No_Press
DEBUG "button"
TOGGLE 1
NEXT
timer:
FOR reps = 1 TO 12 ' repeat with Reps = 1,2,3,etc
PAUSE 60000
NEXT
GOTO motor
No_Press:
GOTO motor
So I'm having trouble with the code for this project. It needs to spin a motor with a paddle wheel attached a certain number of times and then stop for a certain amount of time. The external components (motor ,paddle wheel switch) are working fine. Since the BS1 can't count, I'm using the FOR...NEXT instruction to set a number of loops for both paddle counting and interval timing. I am planning on using FOR...NEXT a large number of times for some of the intervals (~6 to 12 hours). Is there a better way in the BS1? Right now it seems like the BUTTON instruction is resetting the FOR...NEXT instruction for the motor control. Here's the program: Thanks!
SYMBOL btn = 0 ' FOR BUTTON
SYMBOL btnWrk = B4
SYMBOL reps = B2 ' FOR...NEXT loop counter
motor:
HIGH 0
FOR reps = 1 TO 3 ' repeat for 3 button pushes
BUTTON Btn, 7, 1, 255, btnWrk, 0, No_Press
DEBUG "button"
TOGGLE 1
NEXT
timer:
FOR reps = 1 TO 12 ' repeat with Reps = 1,2,3,etc
PAUSE 60000
NEXT
GOTO motor
No_Press:
GOTO motor