code that hangs PICAXE, what's up?

Hemi345

Senior Member
Hi all, so I have the following code that seems to hang the PICAXE:

Code:
[color=Navy]#picaxe [/color][color=Black]08m2[/color]
[color=Navy]#no_data
#terminal 38400[/color]
[color=Blue]setfreq m32
pause [/color][color=Navy]2000[/color]
[color=Blue]sertxd ([/color][color=Red]"Ready."[/color][color=Black],[/color][color=Navy]13[/color][color=Black],[/color][color=Navy]10[/color][color=Blue])[/color]
[color=Black]main:
    [/color][color=Blue]do
        if [/color][color=Purple]pinC.1 [/color][color=DarkCyan]= [/color][color=Navy]1 [/color][color=Blue]then
            reset
        end if
        if [/color][color=Purple]pinC.3 [/color][color=DarkCyan]= [/color][color=Navy]1 [/color][color=Blue]then
            do until [/color][color=Purple]pinC.3 [/color][color=DarkCyan]= [/color][color=Navy]0 [/color][color=Black]: [/color][color=Blue]loop
            sertxd([/color][color=Red]"S1"[/color][color=Black],[/color][color=Navy]13[/color][color=Black],[/color][color=Navy]10[/color][color=Blue])
            serout C.4[/color][color=Black], [/color][color=Blue]T9600_32[/color][color=Black], [/color][color=Blue]([/color][color=Red]"S"[/color][color=Black],[/color][color=Red]"1"[/color][color=Blue])
        end if
        if [/color][color=Purple]pinC.2 [/color][color=DarkCyan]= [/color][color=Navy]1 [/color][color=Blue]then
            do until [/color][color=Purple]pinC.2 [/color][color=DarkCyan]= [/color][color=Navy]0 [/color][color=Black]: [/color][color=Blue]loop
            sertxd([/color][color=Red]"S2"[/color][color=Black],[/color][color=Navy]13[/color][color=Black],[/color][color=Navy]10[/color][color=Blue])
            serout c.4[/color][color=Black], [/color][color=Blue]T9600_32[/color][color=Black], [/color][color=Blue]([/color][color=Red]"S"[/color][color=Black],[/color][color=Red]"2"[/color][color=Blue])
        end if
    sertxd ([/color][color=Red]"Pin"[/color][color=Black],#[/color][color=Purple]pinC.2[/color][color=Black],[/color][color=Navy]13[/color][color=Black],[/color][color=Navy]10[/color][color=Blue])
    pause [/color][color=Navy]2000
    [/color][color=Blue]loop
    

    [/color]
When I pressed the button connected to C.2, the program serout's the string and I see "Pin0" displayed and then the program stops is unresponsive. It's no longer looping because it doesn't respond to any button press.

Anyone see the problem?
 

Hemi345

Senior Member
Nevermind. I left pinC.3 floating which evidently trapped it in the do until pinC.3 = 0 loop once I pressed the button connected to pin C.2. Once I tied that low (ran outta buttons on the AXE091) the program worked as intended.
 

inglewoodpete

Senior Member
You can also use the "PullUp" command on inputs and connect your switches between the input and 0v. It saves on having to use resistors.
 
Top