How to read Keypad with Arduino and I2C

Required Hardware

keypad_pin_diagrami2ckeypad_example_schema

With this library and LCDI2C4Bit you can use one keypad and one lcd (and a lot more devices! like eeproms, etc.) using only two analog pins on arduino.

Wiring Instructions

To wire your PCF8574A to your Arduino, connect the following pins:

  • PCF8574 Pin 1 –> GND
  • PCF8574 Pin 2 –> GND
  • PCF8574 Pin 3 –> GND
  • PCF8574 Pin 4 –> Keypad Pin 1
  • PCF8574 Pin 5 –> Keypad Pin 2
  • PCF8574 Pin 6 –> Keypad Pin 3
  • PCF8574 Pin 7 –> Keypad Pin 4
  • PCF8574 Pin 8 –> GND
  • PCF8574 Pin 9 –> Keypad Pin 5
  • PCF8574 Pin 10 –> Keypad Pin 6
  • PCF8574 Pin 11 –> Keypad Pin 7
  • PCF8574 Pin 12 –> N/C
  • PCF8574 Pin 13 –> N/c
  • PCF8574 Pin 14 –> SCL (A5)
  • PCF8574 Pin 15 –> SDA (A4)
  • PCF8574 Pin 16–> +5V

Add a 220Ohm resistor in series with each column to avoid possible shorts between a HIGH and a LOW line when pushing multiple keys at a time.

Recommended Software

  • none

Instructions and Code

Posted in Arduino Tutorials Tagged with: , , ,
3 comments on “How to read Keypad with Arduino and I2C
  1. thank you for share!

  2. Carlos Lemmi says:

    I have a Waveshare PCF8574 IO Expansion Board with an 4×4 keypad on an Arduino board (Uno or Mega).
    I downloaded “i2ckeypad” library.
    When I run it I get this error:
    ————————————————————————–
    48:26: fatal error: WConstants.h: No such file or directory
    #include “WConstants.h”
    compilation terminated.
    Error compiling.
    ————————————————————————-
    Where do I get “WConstants.h” from, it’s not in the download package?
    WConstants is called from i2ckeypad.h

  3. Ulrich Klaas says:

    Hallo,

    i think that the 220Ohm resitor is not necessary for the PCF because its maximum current is somewhere
    in the range of µA and it cannot be damaged. For a connection directly on the IO-Pins of the
    Atemga they are necessary.

    Is this right ?

    regards
    Ulrich Klaas

1 Pings/Trackbacks for "How to read Keypad with Arduino and I2C"
  1. […] How to read Keypad with Arduino and I2C. With this library and LCDI2C4Bit you can use one keypad and one lcd (and a lot more devices! […]

Leave a Reply

Your email address will not be published. Required fields are marked *

*