Search code examples
user-inputatmegakeypad

atmega32 interfacing taking user input from keypad


Hi I am a newborn person to this AVR coding world .

I am developing a 4*4 keypad to take user inputs and to display some of the things in the 16*2 LCD display.

So please u guys as experts I request your suggestions and explanations of such these points.

I kindly request your help on,

  1. I can't understand the following code parts,

    #define D5 eS_PORTD5 -
    
    DDRD = 0xFF;
    DDRB = 0x0F;
    
  2. is this code fragment is used a predefined function , if so what is that,

    if(bit_is_set (PINB,6))
    

the full code of this is attached herewith.

thank you for your kindness to waste your time on reading this , please help for a beginner if you know evenone of these things.


Solution

  • DDRD = 0xFF sets all bits of register DDRB to 1 which is setting the port D as outputs

    (1 = output, 0 = input)

    DDRB = 0x0F is setting portb low 4 bits as output, upper 4 bits as outputs.

    bit_is_set a #define from sfr_defs.h, in this case, it checks if bit 6 is set from the PINB port.

    it is the equivalent of (PINB & (1<<6))