Connect with us

4x4 matrix with 8255 port expander

Discussion in 'Microcontrollers, Programming and IoT' started by tech_boy, Apr 2, 2012.

Scroll to continue with content
  1. tech_boy

    tech_boy

    4
    0
    Apr 2, 2012
    Hi guys,

    I'm new to this forum.

    I am currently doing my final year school project and i'm finding a difficulty with interfacing a 4x4 matrix keypad with and 8255 port expander (using port C) and all is connected to an 8051 microcontroller.

    I'm using C language and everything is working on a simulator (Proteus) but on the hardware side i'm only able to write text on an LCD but not from the keypad.

    Can anyone help me out pls?
    Any tips and ideas on what to look out for etc etc


    Thanks.
     
  2. Harald Kapp

    Harald Kapp Moderator Moderator

    11,709
    2,717
    Nov 17, 2011
    Oh my, the good old 8255...

    You haven't given a schematic. So let me assume that the 4x4 keypad is connected similar like this:
    C0...C3 = rows of the keypad
    C4...C7 = columns of the keypad
    (You can swap port numbers to fit your circuit).
    There is a button between each row and column at the crossing points, thus 4x4 buttons.
    You will have to configure 4 port pins for input, 4 port pins for output. Assume
    C0...C3 = output
    C4...C7 = input
    You will also need a set of pull-up resistors (or pull down resistors, the choice is your's). Connect one pull-up resistor (e.g. 10 kOhm) from each column to Vcc. This ensures defined High level at the inputs when no button is pressed.

    In order to read from the keyboard, the following sequence can be used:
    program C0=0, C1=1, C2=1, C3=1
    read C4...C7. This will be the state of the first 4 buttons.
    program C0=1, C1=0, C2=1, C3=1
    read C4...C7. This will be the state of the second 4 buttons.
    program C0=1, C1=1, C2=0, C3=1
    read C4...C7. This will be the state of the third 4 buttons.
    program C0=1, C1=1, C2=1, C3=0
    read C4...C7. This will be the state of the fourth 4 buttons.
    You have now the states of all 16 buttons. Any button pressed will appear as "0" on the corresponding input pin, Not pressed buttons will be "1".

    Harald
     
  3. tech_boy

    tech_boy

    4
    0
    Apr 2, 2012
    thanks a lot mate .. I will try that asap :)
     
Ask a Question
Want to reply to this thread or ask your own question?
You'll need to choose a username for the site, which only take a couple of moments (here). After that, you can post your question and our members will help you out.
Electronics Point Logo
Continue to site
Quote of the day

-