Keypad Scan


Posted on Feb 7, 2014

You will be reading input from a keypad and display the corresponding button pressed unto a 7-segment display. You will be required to write a C program which will determine which key has been pressed on the key pad. The program will then display the corresponding character by configuring the output port correctly. The program will be compiled using the C51 compiler and burned onto an 8051 chip.


Keypad Scan
Click here to download the full size of the above Circuit.

A schematic is provided below to show connections needed to implement this lab. Keypads are often used as a primary input device for embedded microcontrollers. The keypads actually consist of a number of switches, connected in a row/column arrangement as shown in Fig 2. In order for the microcontroller to scan the keypad, it outputs a nibble to force one (only one) of the columns low and then reads the rows to see if any buttons in that column have been pressed. The rows are pulled up by the internal weak pull-ups in the 8051 ports. Consequently, as long as no buttons are pressed, the microcontroller sees a logic high on each of the pins attached to the keypad rows. The nibble driven onto the columns always contains only a single 0. The only way the microcontroller can find a 0 on any row pin is for the keypad button to be pressed that connects the column set to 0 to a row. The controller knows which column is at a 0-level and which row reads 0, allowing it to determine which key is pressed. For the keypad, the pins from left to right are: R1, R2, R3, R4, C1, C2, C3, C4. /* main. c */ /* Read from a keypad and display the key pressed */ /* on an 7-segment display */ #pragma SMALL DB OE #include unsigned char SetDisplay(unsigned char value){ unsigned char LookupTable[17] = { 0xC0, . }; /* use code from previous lab */ /* fill in entries to table to handle A, B, C, D, E, F */ } /* Routine to scan the key pressed...




Leave Comment

characters left:

Related Circuits

  • New Circuits

    .

     


    Popular Circuits

    Power Supply for the 8051 Microcontroller
    Breadboard header for ATTiny
    Analog to Digital Converter with ADC0808
    Digital-touch-on-off-switch
    lie detector circuit diagram
    bistable multivibrator using ic 555
    automatic night lamp 230v
    coil coupled operation metal
    8 function christmas lamp
    FET biasing
    Variable Dc Power Supply
    Wideband RF Amplifier



    Top