Hi,
I can't figure out what I'm sure is a simple solution to my problem. I have a NO button that I am trying to just turn on/off an led. I'm using PicBasic (not the pro version) and a 16F818 chip. I've attached my schematic and my code follows. My problem is: when I first power up LEDa and LEDb light up, and when I push the button LEDb turns off and LEDa stays on. My code has nothing to do with LEDb (B1), yet pushing the button affects it. And LEDa stays on constantly. Here's my code:
POKE $8F,%01100000 'SET CLOCK SPEED @4MHZ
SYMBOL TrisB=$86 'PortB data direction Address
SYMBOL PortB=$06 'PortB Pin Address
SYMBOL led=Pin0
SYMBOL pb=Pin7
Poke TrisB,128 'portB 0 to 6 outputs, 7 input
Poke PortB,0 'All off to start
Pause 1000
Start:
If pb=1 then light '??
LOW led 'LED off
GOTO Start 'Return to start
light:
High led 'LED on
GOTO Start 'Return to start
END
Thanks in advance,
Ed
Bookmarks