Interfacing 128x64 Graphic LCD with Arduino

128x64 Graphic LCD

A 128x64 Graphic LCD allows you to display both text and images, making it ideal for projects that require visual feedback. It provides a pixel matrix of 128 columns and 64 rows, offering more control and customization than a standard character LCD.

Working Principle of 128x64 LCD

The 128x64 LCD operates on a dot-matrix grid system where each pixel can be controlled individually. Data is sent from the Arduino to the LCD using parallel or serial communication protocols, depending on the controller (like ST7920 or KS0108).

Types of 128x64 Graphic LCDs

KS0108-based LCD

  • Uses parallel communication for faster data transfer.
  • Requires external library support for drawing functions.
  • Can display both images and multi-line text.

ST7920-based LCD

  • Can operate in SPI or parallel mode.
  • Easy to interface with Arduino using fewer pins in SPI mode.
  • Efficient for drawing complex graphics.

Requirements

1. Arduino Board (Uno/Nano/etc.)

2. 128x64 Graphic LCD (ST7920 or KS0108)

3. Resistors (as per need)

4. Jumper Wires & Breadboard

Pin Configuration of 128x64 Graphic LCD

Common ST7920 Pinout (SPI Mode)

  • VCC: Connect to +5V on Arduino.
  • GND: Connect to GND on Arduino.
  • PSB: Connect to GND for serial mode.
  • RST: Reset pin, connect to a digital pin.
  • E (EN): Connect to SCK (Clock).
  • RW: Connect to MOSI (Data).
  • RS: Register Select, control via Arduino.
  • P1-P8: Not used in serial mode.

Wiring the 128x64 LCD to Arduino

For SPI-based LCDs like the ST7920, connect VCC and GND to the Arduino. Connect the E (clock) and RW (data) pins to designated SPI pins. Use a library to initialize the LCD and begin drawing on the screen. Double-check pin definitions if you're using different Arduino boards.

Algorithm

  1. Initialize Components

    • Connect the LCD pins to the correct Arduino SPI or parallel pins.
    • Use external resistors or a breadboard as needed.
  2. Include and Initialize Library

    • Install and include the U8g2 or GLCD library.
    • Define screen type and communication mode in the code.
    • Begin screen with `begin()` function.
  3. Draw on the Screen

    • Use functions like `drawStr()`, `drawBox()`, and `drawBitmap()`.
    • Add looped animations or sensor values for real-time updates.
  4. Upload and Test

    • Upload the sketch to Arduino.
    • Check for correct display output.
    • Modify positions and shapes as needed.
1#include <U8glib.h>
2
3U8GLIB_ST7920_128X64_1X u8g(13, 11, 10); // (SCK, MOSI, CS)
4
5void setup() {
6  // No setup needed
7}
8
9void loop() {
10  u8g.firstPage();
11  do {
12    u8g.setFont(u8g_font_6x10);
13    u8g.drawStr(10, 30, "Hello 128x64!");
14  } while (u8g.nextPage());
15
16  delay(1000); // Refresh every 1 sec (optional)
17}
18

Applications of 128x64 Graphic LCD

  • Smart home interfaces
  • Weather display systems
  • DIY handheld gaming consoles
  • Sensor data visualization
  • Menu-driven interfaces
  • Oscilloscope or signal viewers

Conclusion

Interfacing a 128x64 Graphic LCD with Arduino opens up creative possibilities for visually rich projects. Whether you're building a weather station or a graphical menu, the LCD's flexibility and sharp resolution make it an excellent display choice.