yas_iiee
Newbie level 5
problem reading port
I m facing prob in reading port of avr ATMega16. I wanna check status of PINC bit 0 and I m using following instruction for the purpose:
if( ( PINC & 0x01 ) == 1)
keyg=1;
else
keyg=0;
obviously data direction is set and external pull-ups are used.
the problem is that unless I force all bits of the port high the statement doesnt work and if any bit gets low it works for 'else'.
Complete code is attatched
I m facing prob in reading port of avr ATMega16. I wanna check status of PINC bit 0 and I m using following instruction for the purpose:
if( ( PINC & 0x01 ) == 1)
keyg=1;
else
keyg=0;
obviously data direction is set and external pull-ups are used.
the problem is that unless I force all bits of the port high the statement doesnt work and if any bit gets low it works for 'else'.
Complete code is attatched