Not sure why the following occurs. When I check with my meter, I get 5V (switch open) and 0V (switch closed), which is the way it should be. However, when I attempt to test the pin for a high or a low, it does not work for me. For example, having a switch connected to PortB.2 and ground, I tried the following simple code:
Code: Select all
main:
DDRB = 0x00 'inputs
PORTB = 0XFF 'all highs
If PortB.2 = 0 then
'Display B2 is low (some statements here)
endif
If PortB.2 = 1 then
'Display B2 is high (some statements here)
endif
end.
I need your help, please. Anything will be greatly appreciated. Thanks in advance.