-
Newbie problem :)
Hi, I have some problems with my code for controlling some leds on my portB.
I use MicroCode Studio/PBP 2.5a/16f877a
TrisA=1
TrisB=0
If portA.0 = 1 then
PortB = %11111111
pause 2000
else
PortB = %00000000
Endif
When I press my key on portA.0 I wont to turn on all leds on portB, they should stay 2sec after I release it, and then turn off. But it wont work, is there some missing code here?
Please help , I am Newbie :)
-
PortA.0 on the 16F877A (as well as many others) is an analog input by default and as such, will not work with 'digital commands'.
You must change it to a digital input.
This is also true of many PICs with built-in ADC's.
-
>>You must change it to a digital input. (from SkiMask)
He is correct - to do this add
before your TRIS commands and all should be well (see datasheet PORTA section for explanation)
-