Totally dumb to this.
lousyshot
Posts: 11
Programming is a foreign language to me.
Entered a simple loop program. How do you stop it without substatuting another program?
Entered a simple loop program. How do you stop it without substatuting another program?
Comments
A microcontroller will do what you tell it to do. If you have a program with a simple loop ... it will loop as long as the chip has power just like you told it to do. If you substitute another program (by downloading a new one to the chip), it will start to do that instead. If you want the loop to stop, you have to provide some statement that will cause the loop to stop so that the program can continue on to something else. Look at the DO / LOOP statement, particularly with a WHILE or UNTIL clause. You could also use a FOR / NEXT loop to loop some specified number of times. You could include an IF / THEN statement somewhere in your simple loop with a GOTO to somewhere else in your program.
If you what to get out of a loop - you have a few options - Count how many times you want to loop and then jump out; or test some condition and when it occurs or doesn't occur, jump out of the loop.
This is NOT rocket science and PBasic is rather easy.
One choice of jumping out ouf a loop is to save power when you no longer need the loop. That is what the END command in PBasic is for, but just putting an END inside a loop destroys the loop. You need to either count or test your loop and after you jump out you can use the END command.
If you want to start again, you hit the RESET button and the cycle begins anew.