LCD I2C Bus with keyboard – PCF8574 version. The PCF version differs, compared to the 4-bit version, by the smaller number of control signals (SCL, SDA). As a result you will have a greater number of signals available for the I/O channels.

This solution is to be preferred because it uses PCF I2C bus, already occupied by (and shared with) RTC and external EEprom. The card also has 4 buttons (whose status is acquired via analog signal). The circuit has been designed to be able to acquire, through the software library of Seletronica, the status of multiple keys pressed simultaneously. On the card there’s a LED used to signal the working status of the module.

The LCD I2C Bus board is designed to be inserted in a modular DIN rail mounting (6 modules). The container allows you to move from the development phase of the software (on the bench) to end use in the field with a simplicity and speed not found in other programmable platforms.

Buy

CPU Connections

The LCD I2C Bus board has two modes of operation determined on the basis of components on the board and the configuration jumpers. The first is the mode with communication interface I2Cbus (with driver PCF8574). This solution lets you use the LCD board without taking up additional resources of the microcontroller as the bus I2Cbus is already used for the clock and EEPROM. The second mode of operation is the parallel 4-bit (please see related section).

The display used for both solutions is always of the type with parallel control (HT44780 compatible). The CPU and the LCD I2C Bus boards are provided by default with the jumpers configured to control the display with I2C bus.

LCD DISPLAY managed in serial mode I2CBus (default)

  • Jumpers from JP1 to JP7: not bridged (not connected)
  • Connector CN4: connected 1-2 and 3-4
LCD DISPLAY jumpers - back view

LCD DISPLAY jumpers – keyboard side

 

LCD DISPLAY jumpers - front view

LCD DISPLAY jumpers – CPU connector side

NOTE: jumpers JP1-JP7 are placed under the physical LCD, therefore they aren’t accessible when LCD is soldered in its place. This is a good reason to choose the right configuration (PCF8574 or parallel 4-bit) before purchase one of them.

Technical specifications

  • LCD type: 16×2 HT44780 compatible
  • Communication bus: I2C
  • Backlight: yes, managed by PCF8574
  • Keyboard: 4 keys
  • Led: 1

Code example

/*==============================================
   ARCHIDUINO is ARDUINO Leonardo compatible
===============================================*/

/*
  Program name: MultiKey
  The program uses the LCD I2C Bus mode (with driver PCF8574)
  The CPU board must be configured using the appropriate jumpers (refer to the manual of the CPU Archiduino)
  Also the LCD board must be configured using the appropriate jumpers (refer to the manual of the CPU Archiduino)
  
  The program displays on top of LCD the analog value of the input on which are connected the keys, in the
  lower part of the LCD shows the status of the keys. The correct state of the buttons is also reported by 
  pressing one or more keys simultaneously

  This software is provided "as is", without technical support, and with no 
  warranty, express or implied, as to its usefulness for any purpose.    
  This example code is in the public domain.
*/

/* Includes ARCHIDUINO libraries */
#include <Archiduino.h>
#include <ArchiduinoLcd.h>
#include <pins_archiduino.h>

/* Includes ARDUINO libraries */
#include <LiquidCrystal.h>
#include <LiquidCrystal_I2C.h>
#include <Wire.h>


ArchiduinoLcd_PCF lcd;        // set the LCD address to 0x20 for a 16 chars and 2 line display

int KeyboardPin = PB4;        // select the input pin of lcd-keyboard
int KeyboardValue;            // variable to store the value coming from the keyboard
int ledPin = LED_RUN;         // select the pin for the LED
bool ledStatus;

void setup()
{  
  delay(1000);  
  lcd.init();                      // initialize the lcd 
  lcd.begin(16, 2);                // initialize lcd and keyboard
  lcd.clear();

  // Print a message to the LCD.
  lcd.backlight();
  lcd.print("   ARCHIDUINO   ");
  lcd.setCursor(0, 1);
  lcd.print("    TEST KEY    ");
  delay(3000);
  lcd.clear();
 
}

void loop()
{
   
  // read the value from the sensor:
  KeyboardValue = analogRead(KeyboardPin);    

  lcd.setCursor(0, 0);
  lcd.print("KEY VALUE: ");  
  lcd.print(KeyboardValue);  
  lcd.print("   ");

  lcd.setCursor(0,1);
  if(lcd.IsButton1Pressed()){lcd.print("1="); lcd.write(255);}else{lcd.print("1="); lcd.write(219);}   
  lcd.setCursor(4,1);
  if(lcd.IsButton2Pressed()){lcd.print("2="); lcd.write(255);}else{lcd.print("2="); lcd.write(219);}   
  lcd.setCursor(8,1);
  if(lcd.IsButton3Pressed()){lcd.print("3="); lcd.write(255);}else{lcd.print("3="); lcd.write(219);}      
  lcd.setCursor(12,1);
  if(lcd.IsButton4Pressed()){lcd.print("4="); lcd.write(255);}else{lcd.print("4="); lcd.write(219);}      

 
  if (ledStatus==0)
  {
    ledStatus = 1;
    lcd.ledOn();      //led run on
  }
  else
  {
    ledStatus = 0;
    lcd.ledOff();    //led run off
  }
  delay(400);    
   
}

 

Attachments

LCD Board Schematic
Title: UPC_LCD1_V1_Schematic (466 clicks)
Caption: LCD Board Schematic
Filename: upc_lcd1_v1_schematic.pdf
Size: 194 KB