I am doing a simple code for my grandsons railway project. I am nearly 80 years old and struggle a bit with these. The problem is at power up C.1 and C.2 immediately turn on and stay that way even though pin3 is low. The only way I can get C.0 and C.4 to light up and the others to go off is to physically connect pin 3 to negative. In picaxe editor if i run the code in simulation it works fine. I wired it up to a breadboard and just get this problem. I am completely lost and would appreciate some advice as to what i am doing wrong. Many thanks.
code:
#picaxe 08m2
Main: 'Ricks Traffic Lights'
if pin3 = 1 then 'actuated by button one on remote switch'
Low c.0 'This ensures light out to start'This is the big green light.
Low c.4 'This ensures light out to start.This is the flashing green light.
High c.1 'This turns on the big red light.
High c.2 'This turns on the flashing red light.
endif
If pin3 =0 then 'actuated by button one on remote switch'
Low c.1 'This turns off the big red light.
Low c.2 'This turns off the flashing red light.
endif
if pin3 = 0 then
High c.0 'This turns on the big green light'
High c.4 'This turns on the flashing green light.
endif
'To go back to start press button one on remote switch.This will turn green lights off.
goto Main:
code:
#picaxe 08m2
Main: 'Ricks Traffic Lights'
if pin3 = 1 then 'actuated by button one on remote switch'
Low c.0 'This ensures light out to start'This is the big green light.
Low c.4 'This ensures light out to start.This is the flashing green light.
High c.1 'This turns on the big red light.
High c.2 'This turns on the flashing red light.
endif
If pin3 =0 then 'actuated by button one on remote switch'
Low c.1 'This turns off the big red light.
Low c.2 'This turns off the flashing red light.
endif
if pin3 = 0 then
High c.0 'This turns on the big green light'
High c.4 'This turns on the flashing green light.
endif
'To go back to start press button one on remote switch.This will turn green lights off.
goto Main: