Dear all, I have a small keyboard in my application and I poll all the keys periodically. I can read all the key values with 2 bytes. Next, I check the bits of these bytes for specific keys. In my program, I have function (check_button()) which gets the byte value and the bit index of the required key. It extracts the bit using '>>' and '<<', and interprets the value.
for (button_index=0; button_index<8; button_index++) check_button(button_port_1, button_index); : : : void check_button(unsigned char buttons, unsigned char button_index) { get the bit using << and >> process it }
for (button_index=0; button_index<8; button_index++) { button_port_1 >>= 1; (I need to get the carry bit) check_button(carry_bit_taken_above, button_index); }