The 12864 LCD is a graphical liquid crystal display with a resolution of 128x64 pixels. Unlike character-based LCDs, this display allows for the rendering of both text and simple graphics, making it a versatile choice for a wide range of applications. It is commonly used in embedded systems, microcontroller projects, and DIY electronics for creating user interfaces, displaying sensor data, or visualizing information in a compact and efficient manner.
Explore Projects Built with 12864 LCD
Use Cirkit Designer to design, explore, and prototype these projects online. Some projects support real-time simulation. Click "Open Project" to start designing instantly!
This circuit features an Arduino Mega 2560 microcontroller connected to a 16x2 LCD display for visual output. A trimmer potentiometer is used to adjust the contrast of the LCD. The Arduino provides power to the LCD and controls it via several PWM pins.
This circuit connects an Arduino Mega 2560 microcontroller to a 3.5-inch 480x320 TFT LCD display. The Arduino provides power, ground, and digital signals to control the display, including data lines for pixel information and control lines for reset, write, and command/data selection. The embedded code initializes the display and configures the Arduino's pins for communication, likely to create a user interface or visual output for a project.
This circuit features an ESP8266 microcontroller interfaced with a 128x64 OLED display via I2C for visual output and an RGB LED controlled through current-limiting resistors. The ESP8266 provides power and control signals to both the display and the LED, enabling visual feedback and status indication.
This circuit features an A-Star 32U4 Mini microcontroller connected to a 16x2 I2C LCD screen. The microcontroller provides power and ground to the LCD, and communicates with it via the I2C protocol using the A4 (SDA) and A5 (SCL) pins.
The 12864 LCD comes in various models, often differentiated by their controller ICs (e.g., ST7920, KS0108). Below are the general technical specifications:
Parameter
Value
Resolution
128x64 pixels
Operating Voltage
4.5V - 5.5V
Operating Current
~20mA (backlight off)
Backlight Current
~100mA (varies by model)
Communication Interface
Parallel, SPI, or I2C (varies by model)
Controller IC
ST7920, KS0108, or compatible
Operating Temperature
-20°C to 70°C
Pin Configuration
The pin configuration may vary depending on the specific model and communication interface. Below is a typical pinout for a 12864 LCD with an ST7920 controller in parallel mode:
Pin
Name
Description
1
VSS
Ground (0V)
2
VDD
Power supply (4.5V - 5.5V)
3
VO
Contrast adjustment (connect to a potentiometer)
4
RS
Register Select (0: Command, 1: Data)
5
RW
Read/Write (0: Write, 1: Read)
6
E
Enable signal (latches data on high-to-low transition)
7-14
DB0-DB7
Data bus lines (used for 8-bit parallel communication)
15
PSB
Interface selection (0: Serial, 1: Parallel)
16
NC
Not connected
17
RST
Reset signal
18
VOUT
Voltage output for LCD drive
19
BLA
Backlight anode (+)
20
BLK
Backlight cathode (-)
For SPI or I2C configurations, the pinout will differ, and additional components (e.g., an I2C backpack module) may be required.
Usage Instructions
Connecting the 12864 LCD to an Arduino UNO
To use the 12864 LCD with an Arduino UNO, you can use the U8g2 library, which supports a wide range of graphical LCDs, including the 12864. Below is an example of how to connect and program the LCD in SPI mode:
Wiring Diagram (SPI Mode)
12864 LCD Pin
Arduino UNO Pin
VSS
GND
VDD
5V
VO
Potentiometer (middle pin)
RS
Pin 9
RW
GND
E (Enable)
Pin 8
PSB
GND (for SPI mode)
RST
Pin 10
DB0-DB7
Not used in SPI mode
BLA
5V
BLK
GND
Example Code
#include <U8g2lib.h>
// Initialize the U8g2 library for ST7920 in SPI mode
// U8G2_ST7920_128X64_F_SW_SPI constructor parameters:
// (clock, data, chip select, reset)
U8G2_ST7920_128X64_F_SW_SPI u8g2(U8G2_R0, /* clock=*/ 13, /* data=*/ 11,
/* CS=*/ 10, /* reset=*/ 8);
void setup() {
u8g2.begin(); // Initialize the display
}
void loop() {
u8g2.clearBuffer(); // Clear the display buffer
u8g2.setFont(u8g2_font_ncenB08_tr); // Set font
u8g2.drawStr(0, 10, "Hello, 12864 LCD!"); // Draw text at (0, 10)
u8g2.sendBuffer(); // Send buffer to the display
delay(1000); // Wait for 1 second
}
Important Considerations
Contrast Adjustment: Use a 10kΩ potentiometer connected to the VO pin to adjust the display contrast.
Backlight Power: Ensure the backlight current does not exceed the power supply's capacity.
Communication Mode: Verify the PSB pin configuration for the desired communication mode (SPI, parallel, or I2C).
Library Compatibility: Use a compatible library like U8g2 for easy integration with microcontrollers.
Troubleshooting and FAQs
Common Issues
Blank Screen
Cause: Incorrect contrast setting or wiring.
Solution: Adjust the potentiometer connected to the VO pin. Double-check the wiring.
No Response from the LCD
Cause: Incorrect communication mode or pin connections.
Solution: Verify the PSB pin configuration and ensure all connections match the selected mode.
Flickering or Unstable Display
Cause: Insufficient power supply or loose connections.
Solution: Ensure a stable 5V power supply and secure all connections.
Text or Graphics Not Displaying Properly
Cause: Incorrect library initialization or code errors.
Solution: Check the library documentation and ensure the correct initialization parameters are used.
FAQs
Can I use the 12864 LCD with a 3.3V microcontroller?
Yes, but you will need a level shifter to convert 3.3V signals to 5V.
What is the maximum cable length for SPI or parallel communication?
For reliable operation, keep the cable length under 30cm to minimize signal degradation.
Can I display custom graphics on the 12864 LCD?
Yes, you can use libraries like U8g2 to draw custom shapes, bitmaps, and animations.
Is the 12864 LCD compatible with Raspberry Pi?
Yes, it can be used with Raspberry Pi via SPI or I2C, but additional configuration may be required.
By following this documentation, you can effectively integrate and troubleshoot the 12864 LCD in your projects.