MrDEB
Well-Known Member
been trying to figure out WHY this code keeps outputting regardless of switch setting.
What it is supposed to do is run only the desired IF THEN statements but it runs all four IF THEN statements. If I have the switch on pos4 (Pg4 = pressed then all three leds light up but the code cycles through all four IF THEN statements.
the rotary switch has the common pin grounded and each position pin is held HIGH
Verified that the correct pic pin is going LOW.
her is the switch, kept looking at switch diagram to be sure I didn't miss anything https://www.mouser.com/ds/2/96/220-786387.pdf
this shouldn't be this hard. I used a working example from my Mexican train game that works but the switches are separate momentary on/off but same code format.
What it is supposed to do is run only the desired IF THEN statements but it runs all four IF THEN statements. If I have the switch on pos4 (Pg4 = pressed then all three leds light up but the code cycles through all four IF THEN statements.
the rotary switch has the common pin grounded and each position pin is held HIGH
Verified that the correct pic pin is going LOW.
her is the switch, kept looking at switch diagram to be sure I didn't miss anything https://www.mouser.com/ds/2/96/220-786387.pdf
this shouldn't be this hard. I used a working example from my Mexican train game that works but the switches are separate momentary on/off but same code format.
IF Pg1=pressed THEN
portA.2=1
portA.3=1
portA.4=1
Ch_10=1 //led on c.5
DELAYMS(1000)
Ch_10=0
DELAYMS(500)
END IF
IF Pg2=pressed THEN
portA.1=1
portA.3=1
portA.4=1
Ch_11=1 //led on d.6
DELAYMS(1000)
Ch_11=0
DELAYMS(500)
END IF
IF Pg3=pressed THEN
portA.1=1
portA.2=1
portA.4=1
Ch_12=1 //led on d.7
DELAYMS(1000)
Ch_12=0
DELAYMS(500)
END IF
IF pg4=pressed THEN
portA.1=1
portA.2=1
portA.3=1
Ch_10=1
Ch_12=1
Ch_11=1
DELAYMS(1000)
Ch_10=0
Ch_12=0
Ch_11=0
DELAYMS(500)
END IF