Adafruit I2C/SPI Character LCD Backpack
Manufacturer
OVERVIEW
This is a very useful adapter to convert the parallel interface of the character LCD display module into I2C or SPI serial interfaces. This conversion reduces the number of LCDD connections to 2~3 wires. MCP23008 AND 74HC595 are two chips that convert serial inputs to parallel outputs. The MCP23008 is a 8-bit I/O expander connected to the I2C serial interface. The 74HC595 is a 8-bit shift register with a latch control to the SPI serial interface.
Technical Details:
MCP23008: 8-bit I2C I/O Expander
- 8-bit remote bidirectional I/O port
- High-speed I2C interface
- 100KHz
- 400KHz
- 1.7MHz
- Hardware slave address pins
- Three address pins [A2:A1:A0] allow up to eight devices on the same I2C bus
- Slave address range: 0x20 to 0x27
- Operating voltage:
- I2C @100KHz: 1.8V to 5.5V @ -40°C ~ +85°C
- I2C @ 400KHz: 2.7V to 5.5V @ -40°C ~ +85°C
- I2C @ 1.7MHz: 4.5V to 5.5V @ -40°C ~ +125°C
74HS595: 8-bit Shift Register with Latch Control
- 8-bit serial input, parallel output shift registers, and storage registers
- Both shift registers and storage registers have separate clocks (SHCP and STCP)
- Data is shifted on the rising-edge of the SHCP input
- Data is transferred from the shift register to the storage registers on the rising-edge of the STCP input
- Storage register with 3-state outputs
- 100MHz (typical) shift out frequency
I2C INTERFACE
By default, the adapter is configured on I2C interface mode. I2C bus uses only two bidirectional pins: Serial Data Line (SDA) and Serial Clock Line (SCL), and also supports multiple I2C devices on the same bus. Each I2C device has a unique Slave Address, so that the I2C master can recognize each slave device. The adapter has 3 address pins. If you need more than one LCD display module on the same I2C bus, you need to configure each adapter in different address by soldering separate jumpers on the [A2:A0] pins. The pin conncetions and I2C configurations are as follow::
- Connection between the MCP23008 and the I2C Interface:
- CLK pin to I2C: SCL pin
- DAT pin to I2C: SDA pin
- Address configuration pins: [A2:A0]
This chip uses I2C 7-bit address with range of 0x20-0x27. The lower-bits of this address are configured by [A2:A0] solder jumpers
- Configuration for I2C Master:
- Bit Rate: 400Kbps
- Data Bit: 8-bit
You can switch between I2C and SPI interface modes bt enabling/disabling the SPI Enable solder jumper:

- I2C Interface Mode:
To enable I2C interface, you have to remove solder on the SPI Enable solder jumper by using solder sucker ot solder wick. - I2C Slave Address Selection
This chip uses I2C 7-bit address with range of 0x20-0x27, configurable with solder jumpers [A2:A0]
SPI INTERFACE
Another option for communicating with adapter is through the SPI interface. Standard SPI interface uses 3 or 4 wires. MOSI, MISO, SCLK and SS are used in 4-wire SPI interface, and SDA, SCLK and SS are used in 3-wire SPI interface. This adapter is using the 74LS595 chip to support SPI communication through the following pins: CLK, DAT and LAT. In this mode, you have to connect 3 wires to the SPI interface: CLK (clock), DAT (data) and LAT (Latch). The pin conncetions and SPI configurations are as follow:
- Connection between the 74LS595 and the SPI Interface:
- CLK pin to SPI: SCLK pin
- DAT pin to SPI: MOSI pin
- LAT pin to SPI: SS pin
- Configuration for SPI Master:
- SPI Mode: CPHA=0, CPOL=0
- Data Bit: 8-bit
- Shift Direction: MSB First
- Bit Rate: 400Kbps
You can switch between I2C and SPI interface modes bt enabling/disabling the SPI Enable solder jumper:

- SPI Interface Mode:
To enable SPI interface, you have to solder a blob on the SPI Enable solder jumper pins.
EZ-PSoC 5LP API
I2C Interface Mode: MCP23008
If you want to use the I2C interface mode, you have to disable SPI Enable solder jumper, and use the LCDMCP23008 sensor object in your PSoC 5LP project.
Required Header File
#include "LCDMCP23008.h"
Required PSoC Creator Component
I2C Master (Fixed Function or UDB)
Object Configurations
Configurations | Description | |
obj->Config.Addr | The I2C slave address. This value must be matched with the board solder jumper [A2:A0] Deafult: 000 |
|
obj->Config.LcdLine | The number of lines on the LCD Default: 4 |
|
obj->Config.LcdCols | The number of columns on the LCD Default: 20 |
|
obj->Config.DotSize | Configures the font size (dots) = LCD74HS595_LCD_5x8DOTS: The font size is 5x8 dots (Default) = LCD74HS595_LCD_5x10DOTS: The font size is 5x10 dots |
|
Object API:
Functions | Description |
LCDMCP23008_Create() | Creates adapter (sensor) object |
LCDMCP23008_Release() | Releases adapter (sensor) object |
LCDMCP23008_ConnectI2C() | Connects with the I2C hardware interface object |
LCDMCP23008_Init() | Performs initialization and configuration of the adapter |
LCDMCP23008_Start() | Starts the adapter, enables communication interface, and turns on the LCD |
LCDMCP23008_SetBacklightOn() | Turns on the LCD backlight |
LCDMCP23008_SetBacklightOff() | Turns off the LCD backlight |
LCDMCP23008_DisplayOn() | Turns on the LCD module's display |
LCDMCP23008_DisplayOff() | Turns off the LCD module's display |
LCDMCP23008_ClearDisplay() | Clears data from the LCD module screen |
LCDMCP23008_Position() | Sets the cursor's position to match the row and column specified by the user |
LCDMCP23008_PutChar() | Prints a single character (at the current position) to the screen |
LCDMCP23008_PrintString() | Prints a null-terminated string to the screen |
LCDMCP23008_PrintInt8() | Prints an unsigned 8-bit integer to the LCD display in a 2-digit hex ASCII string |
LCDMCP23008_PrintInt16() | Prints an unsigned 16-bit integer to the LCD display in a 4-digit hex ASCII string |
LCDMCP23008_PrintInt32() | Prints an unsigned 32-bit integer to LCD display in a 8-digit hex ASCII string |
LCDMCP23008_PrintNumber() | Prints the decimal value of a 16-bit value as left-justified ASCII string |
LCDMCP23008_PrintU32Number() | Prints the decimal value of a 32-bit value as left-justified ASCII string |
Detail Function
PEZOBJ_LCDMCP23008 LCDMCP23008_Create(void) | ||
Description: | This function creates the MCP23008 adapter (sensor) object | |
Parameters: | None | |
Return Value: | The MCP23008 object | |
void LCDMCP23008_Release(PEZOBJ_LCDMCP23008 lcd) | ||
Description: | This function destroys the MCP23008 adapter (sensor) object | |
Parameters: | PEZOBJ_LCDMCP23008 lcd: MCP23008 sensor object | |
Return Value: | None | |
void LCDMCP23008_ConnectI2C(PEZOBJ_LCDMCP23008 lcd, PEZOBJ_I2C i2c) | ||
Description: | This function connects the MCP23008 sensor object with the I2C interface object | |
Parameters: |
PEZOBJ_LCDMCP23008 lcd: MCP23008 sensor object |
|
Return Value: | None | |
bool LCDMCP23008_Init (PEZOBJ_LCDMCP23008 lcd) | ||
Description: | Performs initialization and configuration of the LCD screen | |
Parameters: | PEZOBJ_LCDMCP23008 lcd: MCP23008 sensor object | |
Return Value: | bool: (= true) Initialization success; (= false) Initialization error | |
void LCDMCP23008_Start(PEZOBJ_LCDMCP23008 lcd) | ||
Description: | Starts up the module and loads default configuration settings to the LCD | |
Parameters: | PEZOBJ_LCDMCP23008 lcd: MCP23008 sensor object | |
Return Value: | None | |
void LCDMCP23008_SetBacklightOn(PEZOBJ_LCDMCP23008 lcd) | ||
Description: | Turns on the backlight LED | |
Parameters: | PEZOBJ_LCDMCP23008 lcd: MCP23008 sensor object | |
Return Value: | None | |
void LCDMCP23008_SetBacklightOff(PEZOBJ_LCDMCP23008 lcd) | ||
Description: | Turns off the backlight LED | |
Parameters: | PEZOBJ_LCDMCP23008 lcd: MCP23008 sensor object | |
Return Value: | None | |
void LCDMCP23008_ClearDisplay(PEZOBJ_LCDMCP23008 lcd) | ||
Description: | Clears the contents of the LCD screen and resets the cursor location to row zero and column zero. | |
Parameters: | PEZOBJ_LCDMCP23008 lcd: MCP23008 sensor object | |
Return Value: | None | |
void LCDMCP23008_Position(PEZOBJ_LCDMCP23008 lcd, uint8 row, uint8 col) | ||
Description: | Moves the cursor to the location specified by row and column. | |
Parameters: | PEZOBJ_LCDMCP23008 lcd: MCP23008 sensor object uint8 row: The row where the cursor will be positioned at. Minimum value - zero. uint8 col: The column where the cursor will be positioned at. Minimum value - zero. |
|
Return Value: | None | |
void LCDMCP23008_PrintString(PEZOBJ_LCDMCP23008 lcd, char8 string[]) | ||
Description: | Prints a null-terminated string of characters to the screen beginning at the current cursor position | |
Parameters: | PEZOBJ_LCDMCP23008 lcd: MCP23008 sensor object char8 const string[]: Null-terminated array of ASCII characters to be displayed on the LCD screen |
|
Return Value: | None | |
void LCDMCP23008_PutChar(PEZOBJ_LCDMCP23008 lcd, uint8_t character) | ||
Description: | Prints an individual character to the screen at the current cursor position | |
Parameters: | PEZOBJ_LCDMCP23008 lcd: MCP23008 sensor object char8 character: ASCII character to be displayed on the LCD screen |
|
Return Value: | None | |
void LCDMCP23008_PrintInt8(PEZOBJ_LCDMCP23008 lcd, uint8 value) void LCDMCP23008_PrintHexUint8(PEZOBJ_LCDMCP23008 lcd, uint8 value) |
||
Description: | Prints an unsigned 8-bit integer to the LCD display in a 2-digit hex ASCII string | |
Parameters: | PEZOBJ_LCDMCP23008 lcd: MCP23008 sensor object uint8 value: The 8-bit value to be printed in hexadecimal ASCII characters |
|
Return Value: | None | |
void LCDMCP23008_PrintInt16(PEZOBJ_LCDMCP23008 lcd, uint16 value) void LCDMCP23008_PrintHexUint16(PEZOBJ_LCDMCP23008 lcd, uint16 value) |
||
Description: | Prints an unsigned 16-bit integer to the LCD display in a 4-digit hex ASCII string | |
Parameters: | PEZOBJ_LCDMCP23008 lcd: MCP23008 sensor object uint16 value: The 16-bit value to be printed in hexadecimal ASCII characters |
|
Return Value: | None | |
void LCDMCP23008_PrintInt32(PEZOBJ_LCDMCP23008 lcd, uint32 value) | ||
Description: | Prints an unsigned 32-bit integer to LCD display in a 8-digit hex ASCII string | |
Parameters: | PEZOBJ_LCDMCP23008 lcd: MCP23008 sensor object uint32 value: The 32-bit value to be printed in hexadecimal ASCII characters |
|
Return Value: | None | |
void LCDMCP23008_PrintU32Number(PEZOBJ_LCDMCP23008 lcd, uint32 value) void LCDMCP23008_PrintNumber(PEZOBJ_LCDMCP23008 lcd, uint16 value) void LCDMCP23008_PrintDecUint16(PEZOBJ_LCDMCP23008 lcd, uint16 value) |
||
Description: | Prints an unsigend 16/32-bit integer value as left-justified decimal ASCII characters | |
Parameters: | PEZOBJ_LCDMCP23008 lcd: MCP23008 sensor object uint32/uint16 value: The 16/32-bit value to be printed in ASCII characters as decimal number |
|
Return Value: | None |
SPI Interface Mode: 74LS595
If you want to use SPI interface mode, you have to enable SPI Enable solder jumper, and use LCD74HS595 sensor object in your PSoC 5LP project.
Required Header File
#include "LCD74HS595.h"
Required PSoC Creator Component
SPI Master Bidirectional mode Marco
Object Configurations
Configurations | Description | |
obj->Config.Addr | The SPI SS (Slave Select) decoder number. This value is only used when you connect multiple SPI devices on the same bus and use SS decoder. Deafult: 0 |
|
obj->Config.LcdLine | The number of lines on the LCD Default: 4 |
|
obj->Config.LcdCols | The number of columns on the LCD Default: 20 |
|
obj->Config.DotSize |
Configures the font size (dots) |
|
Object API:
Functions | Description |
LCD74HS595_Create() | Creates adapter (sensor) object |
LCD74HS595_Release() | Releases adapter (sensor) object |
LCD74HS595_ConnectSPI() | Connects with the SPI hardware interface object |
LCD74HS595_Init() | Performs initialization and configuration of the adapter |
LCD74HS595_Start() | Starts the adapter, enables communication interface, and turns on the LCD |
LCD74HS595_SetBacklightOn() | Turns on the LCD backlight |
LCD74HS595_SetBacklightOff() | Turns off the LCD backlight |
LCD74HS595_DisplayOn() | Turns on the LCD module's display |
LCD74HS595_DisplayOff() | Turns off the LCD module's display |
LCD74HS595_ClearDisplay() | Clears data from the LCD screen |
LCD74HS595_Position() | Sets the cursor's position to match the row and column specified by the user |
LCD74HS595_PutChar() | Prints a single character (at the current position) to the screen |
LCD74HS595_PrintString() | Prints a null-terminated string to the screen |
LCD74HS595_PrintInt8() | Prints an unsigned 8-bit integer to the LCD display in a 2-digit hex ASCII string |
LCD74HS595_PrintInt16() | Prints an unsigned 16-bit integer to the LCD display in a 4-digit hex ASCII string |
LCD74HS595_PrintInt32() | Prints an unsigned 32-bit integer to LCD display in a 8-digit hex ASCII string |
LCD74HS595_PrintNumber() | Prints the decimal value of a 16-bit value as left-justified ASCII string |
LCD74HS595_PrintU32Number() | Prints the decimal value of a 32-bit value as left-justified ASCII string |
Detail Function
PEZOBJ_LCD74HS595 LCD74HS595_Create(void) | ||
Description: | This function creates the LCD74HS595 adapter (sensor) object | |
Parameters: | None | |
Return Value: | The LCD74HS595 object | |
void LCD74HS595_Release(PEZOBJ_LCD74HS595 lcd) | ||
Description: | This function destroys the LCD74HS595 adapter (sensor) object | |
Parameters: | PEZOBJ_LCD74HS595 lcd: LCD74HS595 sensor object | |
Return Value: | None | |
void LCD74HS595_ConnectSPI(PEZOBJ_LCD74HS595 lcd, PEZOBJ_SPI spi) | ||
Description: | This function connects the 74HS595 sensor object with the SPI interface object | |
Parameters: |
PEZOBJ_LCD74HS595 lcd: LCD74HS595 sensor object |
|
Return Value: | None | |
bool LCD74HS595_Init (PEZOBJ_LCD74HS595 lcd) | ||
Description: | Performs initialization and configuration of the LCD screen | |
Parameters: | PEZOBJ_LCD74HS595 lcd: LCD74HS595 sensor object | |
Return Value: | bool: (= true) Initialization success; (= false) Initialization error | |
void LCD74HS595_Start(PEZOBJ_LCD74HS595 lcd) | ||
Description: | Starts up the module and loads default configuration settings to the LCD | |
Parameters: | PEZOBJ_LCD74HS595 lcd: LCD74HS595 sensor object | |
Return Value: | None | |
void LCD74HS595_SetBacklightOn(PEZOBJ_LCD74HS595 lcd) | ||
Description: | Turns on the backlight LED | |
Parameters: | PEZOBJ_LCD74HS595 lcd: LCD74HS595 sensor object | |
Return Value: | None | |
void LCD74HS595_SetBacklightOff(PEZOBJ_LCD74HS595 lcd) | ||
Description: | Turns off the backlight LED | |
Parameters: | PEZOBJ_LCD74HS595 lcd: LCD74HS595 sensor object | |
Return Value: | None | |
void LCD74HS595_ClearDisplay(PEZOBJ_LCD74HS595 lcd) | ||
Description: | Clears the contents of the LCD screen and resets the cursor location to row zero and column zero | |
Parameters: | PEZOBJ_LCD74HS595 lcd: LCD74HS595 sensor object | |
Return Value: | None | |
void LCD74HS595_Position(PEZOBJ_LCD74HS595 lcd, uint8 row, uint8 col) | ||
Description: | Moves the cursor to the location specified by row and column | |
Parameters: | PEZOBJ_LCD74HS595 lcd: LCD74HS595 sensor object uint8 row: The row where the cursor will be positioned at. Minimum value - zero uint8 col: The column where the cursor will be positioned at. Minimum value - zero.. |
|
Return Value: | None | |
void LCD74HS595_PrintString(PEZOBJ_LCD74HS595 lcd, char8 string[]) | ||
Description: | Prints a null-terminated string of characters to the screen beginning at the current cursor position | |
Parameters: | PEZOBJ_LCD74HS595 lcd: LCD74HS595 sensor object char8 const string[]: Null-terminated array of ASCII characters to be displayed on the LCD screen |
|
Return Value: | None | |
void LCD74HS595_PutChar(PEZOBJ_LCD74HS595 lcd, uint8_t character) | ||
Description: | Prints an individual character to the screen at the current cursor position | |
Parameters: | PEZOBJ_LCD74HS595 lcd: LCD74HS595 sensor object char8 character: ASCII character to be displayed on the LCD screen |
|
Return Value: | None | |
void LCD74HS595_PrintInt8(PEZOBJ_LCD74HS595 lcd, uint8 value) void LCD74HS595_PrintHexUint8(PEZOBJ_LCD74HS595 lcd, uint8 value) |
||
Description: | Prints an unsigned 8-bit integer to the LCD display in a 2-digit hex ASCII string | |
Parameters: | PEZOBJ_LCD74HS595 lcd: LCD74HS595 sensor object uint8 value: The 8-bit value to be printed in hexadecimal ASCII characters |
|
Return Value: | None | |
void LCD74HS595_PrintInt16(PEZOBJ_LCD74HS595 lcd, uint16 value) void LCD74HS595_PrintHexUint16(PEZOBJ_LCD74HS595 lcd, uint16 value) |
||
Description: | Prints an unsigned 16-bit integer to the LCD display in a 4-digit hex ASCII string | |
Parameters: | PEZOBJ_LCD74HS595 lcd: LCD74HS595 sensor object uint16 value: The 16-bit value to be printed in hexadecimal ASCII characters |
|
Return Value: | None | |
void LCD74HS595_PrintInt32(PEZOBJ_LCD74HS595 lcd, uint32 value) | ||
Description: | Prints an unsigned 32-bit integer to LCD display in a 8-digit hex ASCII string | |
Parameters: | PEZOBJ_LCD74HS595 lcd: LCD74HS595 sensor object uint32 value: The 32-bit value to be printed in hexadecimal ASCII characters |
|
Return Value: | None | |
void LCD74HS595_PrintU32Number(PEZOBJ_LCD74HS595 lcd, uint32 value) void LCD74HS595_PrintNumber(PEZOBJ_LCD74HS595 lcd, uint16 value) void LCD74HS595_PrintDecUint16(PEZOBJ_LCD74HS595 lcd, uint16 value) |
||
Description: | Prints an unsigend 16/32-bit integer value as left-justified decimal ASCII characters | |
Parameters: | PEZOBJ_LCD74HS595 lcd: LCD74HS595 sensor object uint32/uint16 value: The 16/32-bit value to be printed in ASCII characters as decimal number |
|
Return Value: | None |
Example Code: I2C Interface (Using MCP23008)
#include <stdlib.h> #include "ezI2C.h" #include "LCDMCP23008.h" PEZOBJ_LCDMCP23008 lcd; PEZOBJ_I2C i2c; uint8 cnt = 0; bool bLcdBkl = false; int main() { CyGlobalIntEnable; /* Enable global interrupts. */ /* Place your initialization/startup code here (e.g. MyInst_Start()) */ i2c = ezI2C_Create(); CONNECT_I2C(i2c, I2C); ezI2C_Start(i2c); lcd = LCDMCP23008_Create(); LCDMCP23008_ConnectI2C(lcd, i2c); lcd->Config.LcdLines = 4; lcd->Config.LcdCols = 20; LCDMCP23008_Start(lcd); LCDMCP23008_ClearDisplay(lcd); LCDMCP23008_Position(lcd, 0, 0); LCDMCP23008_PrintString(lcd, "Hello !!"); for(;;) { /* Place your application code here. */ LCDMCP23008_Position(lcd, 0, 10); LCDMCP23008_PrintHexUint8(lcd, cnt); LCDMCP23008_Position(lcd, 1, 10); LCDMCP23008_PrintNumber(lcd, cnt+10000); LCDMCP23008_Position(lcd, 2, 10); LCDMCP23008_PrintNumber(lcd, cnt+20000); LCDMCP23008_Position(lcd, 3, 10); LCDMCP23008_PrintNumber(lcd, cnt+30000); CyDelay(250); cnt ++; if (cnt > 250){ bLcdBkl = ~bLcdBkl; cnt = 0; if (bLcdBkl) LCDMCP23008_SetBacklightOff(lcd); else LCDMCP23008_SetBacklightOn(lcd); } } }
Example Code: SPI Interface (Using 74HS595)
#include <stdlib.h> #include "ezSPI.h" #include "LCD74HS595.h" PEZOBJ_LCD74HS595 lcd; PEZOBJ_SPI spi; uint8 cnt = 0; bool bLcdBkl = false; int main() { CyGlobalIntEnable; /* Enable global interrupts. */ /* Place your initialization/startup code here (e.g. MyInst_Start()) */ spi = ezSPI_Create(); CONNECT_SPI(spi, SPI); ezSPI_Start(spi); lcd = LCD74HS595_Create(); LCD74HS595_ConnectSPI(lcd, spi); LCD74HS595_Start(lcd); LCD74HS595_ClearDisplay(lcd); LCD74HS595_Position(lcd, 0, 0); LCD74HS595_PrintString(lcd, "Hello !!"); for(;;) { /* Place your application code here. */ LCD74HS595_Position(lcd, 0, 10); LCD74HS595_PrintHexUint8(lcd, cnt); LCD74HS595_Position(lcd, 1, 10); LCD74HS595_PrintNumber(lcd, cnt+10000); LCD74HS595_Position(lcd, 2, 10); LCD74HS595_PrintNumber(lcd, cnt+20000); LCD74HS595_Position(lcd, 3, 10); LCD74HS595_PrintNumber(lcd, cnt+30000); cnt ++; if (cnt > 250){ bLcdBkl = ~bLcdBkl; cnt = 0; if (bLcdBkl) LCD74HS595_SetBacklightOff(lcd); else LCD74HS595_SetBacklightOn(lcd); } } }