Author Topic: How to add 6 buttons to a PCF8574 I2C HD44780 LCD display  (Read 1516 times)

0 Members and 1 Guest are viewing this topic.

Offline profdc9Topic starter

  • Frequent Contributor
  • **
  • Posts: 319
  • Country: us
How to add 6 buttons to a PCF8574 I2C HD44780 LCD display
« on: March 22, 2019, 04:39:02 am »
A quick note on how to add 6 buttons to a PCF8574 I2C display, like the kind you commonly get on ebay/aliexpress, so you can get a convenient input interface to your project.

If you are willing to forego controlling the backlight, you can easily add 6 buttons to a PCF8574 I2C LCD display.  See the attached schematic.

The modifications required are:

1.  Remove the transistor Q1 that controls the backlight (it is a small SOT-23 transistor).
2.  Connect the "K" of pin 16 of the backlight LED source to ground (pin 1) if you still want the backlight to be lit when powered on.
3.  There is a 4.7k 0805 SMD resistor between +5V/VDD and pin 7 of the PCF8574.  Solder a small wire to the pad of the resistor connected to pin 7.
4.  Construct a keypad of six buttons, each button in series with a 1N4148 diode.  The cathodes of the diodes (the terminal with the band) are all connected together and to the pad you soldered to for pin 3.
5.  The other terminal of each button is connected to the following 6 pins on the display: RS(4),R/W(5),DB4(11),DB5(12),DB6(13),DB7(14).

As long as the backlight pin (P3 on the PCF8574) is high, the display behaves normally.  To read the buttons, keep the P2/ENABLE(6) pin on the display low and pull the P3/backlight pin low, and all other pins (P0,P1,P4-P7) are high, so a I2C write is performed with the value 0xF3.  Because the pins of the PCF8574 have weak pullups and strong current sinks, when P3 is low, each pin of the display is shorted to P3/low which registers the button press as a zero.   A I2C read then reads the state of the pins in P0,P1,P4-P7 with a low state for a button press.  To restore normal operation, put the P3/backlight pin high again, or I2C write 0xFB.

I have a modified LiquidCrystal_I2C library that includes reading the buttons as well.

Dan
 
The following users thanked this post: obiwanjacobi, ewqstar

Offline ewqstar

  • Newbie
  • Posts: 1
  • Country: ua
Re: How to add 6 buttons to a PCF8574 I2C HD44780 LCD display
« Reply #1 on: July 06, 2022, 06:47:00 am »
Hello. Can you post the modified library?
 

Offline blink_blink_blink

  • Newbie
  • Posts: 1
  • Country: ca
Re: How to add 6 buttons to a PCF8574 I2C HD44780 LCD display
« Reply #2 on: January 15, 2023, 01:34:19 am »
This is pretty cool. I came up with pretty much the same idea independently after a lot of messing around.

You don't need to sacrifice the backlight pin though - just use the LCD enable pin as common for all the switches. It has to be low anyway when the LCD isn't being used.
 


Share me

Digg  Facebook  SlashDot  Delicious  Technorati  Twitter  Google  Yahoo
Smf