I see what you are saying, Henrik. @ Acetronics2: I have been reading the reference manual and better understand now that a CONSTANT would not be the best modifier for this situation. I am trying to use a single push button switch to toggle between 2 different LEDs X 2, so that one half of the 1/2 PIC12F675a (GPIO.0,1,2) performs this function and the other half of 1/2 PIC12F675b (GPIO.3,4,5) performs the exact same function with an entirely different push button and set of LEDs. And also that both halves perform separate from one another.
Here is my new code. The toggle of the LEDs works good, but I am still having the same problem as before.
Code:LED1 var GPIO.0 ' Alias GPIO.0 to LED1 LATCH1 var GPIO.1 'Alias GPIO.1 to LATCH1 PB1 Var GPIO.2 ' Alias GPIO.2 to push button LED1on var word LED1off var word LED2 var GPIO.5 LATCH2 var GPIO.4 PB2 var GPIO.3 LED2on var word LED2off var word ANSEL = 0 ' Set all digital CMCON = 7 ' Analog comparators off TRISIO = %11001100 LED1 = 0 LATCH1 = 1 LED1off = LED1 LED1on = LATCH1 LED2 = 0 LATCH2 = 1 LED2off = LED2 LED2on = LATCH2 main: if PB1 = 0 then pause 10 gosub LED1status LED1on = 1 LED1off = 0 endif if PB2 = 0 then pause 10 gosub LED2status LED2on = 1 LED2off = 0 endif do until PB1 = 1 pause 5 loop do until PB2 = 1 pause 5 loop pause 10 goto main End LED1status: if LED1 = 1 then LATCH1 = LED1on LED1 = LED1off elseif LED1 = 0 then LED1 = LED1on LATCH1 = LED1off endif return LED2status: if LED2 = 1 then LATCH2 = LED2on LED2 = LED2off elseif LED2 = 0 then LED2 = LED2on LATCH2 = LED2off endif return




Bookmarks