View Full Version : variables/program resetting after serin command
11-09-2006, 03:03 AM
when I have the attached program running on my stamp and I send successive commands to the stamp via the serin command it seems to reset everything to off (like a reset).· If I uncomment the "goto startflash" line then the program just runs the "startflash" routine anytime anything is sent down the serial line, and then the other commands are ignored.
Any information will be greatly appreciated.
11-09-2006, 03:15 AM
another bit of information:
when I send "65444" down the line it will turn on the irled pin for me(the IR LED turns on)
If I then send another "65444" the IR LED blinks
If I send some number less than 65000 the program correctly goes and blinks the white LED for the correct duration, but turns off the IR LED first
again any help will be greatly appreciated.
11-09-2006, 03:31 AM
GOTO is a hotly debated programming topic, based on the tendency to produce spaghetti code. In other words, program flow can be a mess. Most programmers avoid it, or limit it's use to something like breaking out of a loop.
Instead of using GOTO, try using GOSUB instead. Make sure you put a return statement at the end of each subroutine. This will return program flow back to the point of departure. Also, if TOP is intended to loop, you can nest the contents in a DO..LOOP contruct, instead of GOTO TOP.
11-09-2006, 03:36 AM
It seems your stamp is browning out and rebooting.
Is the green LED on the STAMP going dim or pulsing? That is a sure sign of too much current being drawn by the circuit.
1. Perhaps your battery is low
2. You are drawing too much current through the LED's , try 1k resistors to just to test
3. Perhaps you have a short in the wiring.
Think outside the BOX!
11-09-2006, 04:31 AM
about the GOTO statements in the code. I had the entire thing written with GOSUB and RETURN, but saw that if the RETURN statement was reached without a calling GOSUB it would send the program back to the first line of code (mimicking the problem I'm having). So I rewrote the whole thing with GOTO's instead just as a test and that is the one that I posted...