Hi, a newbie to digital here. I'm having trouble getting a PIC16f628A to do more than one function at once with switches.
I have two switches and two LEDs. One switch operates one LED, the other switch operates the second LED.
I need each LED to operate independently of one another and together when their respective switches are activated. Right now, one switch interupts the others function. Here is my code:
Swstb var Porta.0 ' switchstb is on porta.0
Switchleft VAR PORTA.3 ' switchleft is on portb.0
LTS VAR PORTB.0 ' left portb.0
STB VAR PORTB.5 ' STB
TRISA.0 = 1 ' porta.0 is now an input
TRISA.3 = 1 ' Porta.3 is now an input
TRISB.0 = 0 ' Portb.0 is left
TRISB.5 = 0 ' Portb.5 is STB
Main:
IF Switchleft = 0 THEN left 'Pressing switch lights left led
if switchstb = 0 then strobe 'Pressing switch stobes led
Lts = 0 ' If switch is pressed, light the LED otherwise turn it OFF
stb = 0 ' If switch is pressed, strobe the LED otherwise turn it OFF
pause 83
GOTO Main
left:
LTS = 1 'Turn ON LTS
Pause 333 'Wait .333 seconds
LTS = 0 'Turn OFF LTS
Pause 333 'Wait .333 seconds
GOTO Main
strobe:
stb = 1 'Turn on strobe
pause 100 'wait for .1 seconds
stb = 0 'Turn off strobe
pause 100 'wait for .1 seconds
goto main
GOTO Main
Any help on this is greatly appreciated.
Bookmarks