When sw0 is closed, led0 turns on, and when sw0 is open led0 turns off.
However when sw0 stays on I cannot turn on the rest of led,s (led1, led2, and led3) when their appropriate switches are on.
Can someone please tell me what am I doing wrong? Thanks.
Comments
1) You have IF ... THEN <label> when you should have IF ... THEN GOSUB <label>
2) You set the I/O pins HIGH, but you never set them LOW (turn them off). What do you want to do about that?
Note that you have RETURNs, but you never do a GOSUB. That's a serious programming error. A GOSUB calls a subroutine and a RETURN returns from that GOSUB.
Be careful about indenting. The indented statements after each IF THEN statement look like they're controlled by the IF THEN statement because they're indented. They're actually at the same "level" as the IF THEN and will always be executed. In Spin (for the Propeller), the indenting works and statements indented after an IF are controlled by the IF's condition, but not in Basic.
I don't understand your comments on the indentation. I idented so that the IF...THEN... statements stands out clearly.
It's ok to use indenting to make the IF THEN statement stand out. Some programming languages (like Spin and Python) use indenting to show statement dependency. Most others do not. In Stamp Basic, there's another form of the IF THEN statement where the THEN is paired with a subsequent ENDIF and everything in-between is controlled by the IF condition. Often indenting is used between the IF and ENDIF statements to clarify which statements are controlled by the IF.