PDA

View Full Version : LCDOUT -> Count Value



eoasap
- 12th October 2005, 03:29
I'm having a hard time trying to do this. this is my configuration and code so far if anyone can help:

hardware: PIC16F84
PORTB.2 has a pullup resistor to VCC
pushbutton switch connected to PORTB.2 to gnd.


I inserted 'high pushbutton' because once i press the button, the output port did not automatically go back to VCC afterwards (right?, wrong?)

CounterA var Byte 'for counter
PushButton var PORTB.2

If PushButton=0 then
CounterA=CounterA+1
pause 10
high pushbutton
Pause 10
While Pushbutton=0:Wend
Lcdout $fe, 1, "Button Presses =" ' Clear LCD screen
Lcdout $FE, $c0, Countera
Pause 2000
endif

tegel2
- 12th October 2005, 12:07
By making the pin High, you have made the port an output !!!

You are then shorting the output to ground and may have damaged your Pic.

eoasap
- 12th October 2005, 13:31
ahh!!! so remove the pullup resistor then and hope the chip isn't fried? does the rest of the code look ok?

tegel2
- 12th October 2005, 14:14
Keep the resistor - a good value is 10k

CounterA var Byte 'for counter
PushButton var PORTB.2

CounterA=0 ' will be an undefined value on startup

Start:

If PushButton=0 then
CounterA=CounterA+1

Lcdout $fe, 1, "Button Presses =" ' Clear LCD screen
Lcdout $FE, $c0, Countera
While Pushbutton=0:Wend
Pause 2000
endif

goto start ' must tell the program where to go otherwise it will crash

eoasap
- 13th October 2005, 00:41
hmm, still not working. i think i need to try to setup an interrupt. this way regardless of what the program is doing it'll record the button press. i'll poke around the forums and see what i can learn ;)

Thanks alot for your help! :)