Shop OBEX P1 Docs P2 Docs Learn Events
variables/program resetting after serin command — Parallax Forums

variables/program resetting after serin command

Eric WarnerEric Warner Posts: 3
edited 2006-11-08 20:31 in BASIC Stamp
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.

Thanks,

Eric

Comments

  • Eric WarnerEric Warner Posts: 3
    edited 2006-11-08 19:15
    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.

    Thanks
  • Kevin WoodKevin Wood Posts: 1,266
    edited 2006-11-08 19:31
    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.
  • metron9metron9 Posts: 1,100
    edited 2006-11-08 19:36
    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!
  • Eric WarnerEric Warner Posts: 3
    edited 2006-11-08 20:31
    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...
Sign In or Register to comment.