How to use Arduino mega with lcd 128x64

Hi! I was trying to use my lcd display 128x64 with my Arduino mega 2560, but lcd display doesn’t shoving the text!

I’m using u8g2 library

I connected it like this:

Can someone help me please?

Please confirm that both photos refer to the actual item on your desk.

Please quote the u8g2lib example sketch by name and copy-paste the constructor statement.


Read the forum guidelines. Post your test code in code tags. Use the IDE autoformat tool (ctrl-t or Tools, Auto Format) to indent the code for readability before posting code.

Thank you, here is my library example name and constructor statement
u8g2 > page_buffer > HelloWorld

U8G2_ST7920_128X64_1_HW_SPI u8g2(U8G2_R0, /* CS=/ 10, / reset=*/ 8);

#include <Arduino.h>
#include <U8g2lib.h>

#ifdef U8X8_HAVE_HW_SPI
#include <SPI.h>
#ifdef U8X8_HAVE_HW_I2C
#include <Wire.h>

U8G2_ST7920_128X64_1_HW_SPI u8g2(U8G2_R0, /* CS=*/ 10, /* reset=*/ 8);

void setup(void) {

void loop(void) {
  do {
    u8g2.drawStr(0,24,"Hello World!");
  } while ( u8g2.nextPage() );


Your constructor matches the connections in photo#2 in message#1.

So I would expect everything to work 100%.

The typical Ebay module that looks like photo #1 has the contrast set automatically. However some pcbs have a small potentiometer which is probably labelled VR1. Make note of its current setting. Then try adjusting.

I would check the wires first. It is not uncommon to have broken wires in cheap Chinese jumpers.


Okay thanks for your answer.
Also I forgot to say, this lcd display works with Arduino nano, but doesn’t work with arduino mega

Of course it won't. HW SPI is on different pins for the MEGA2560. i.e. you should use LCD_RW=MOSI=D51 and LCD_E=SCK=D52

Your photo#2 implied a Nano / Uno. I would expect Nano / Uno to work 100%.

Seriously, GLCDs are pretty slow. There is no harm in using SW_SPI. In which case you can choose the same Dn pins for every target board.

Also note that ST7920 does not play cricket on the SPI bus. If you want to use other SPI devices, remove the ST7920 from the HW SPI pins.

Thank you so much!!! I solved it, now it works :wink:
I connected rw and E like this:

R/W - D51

E - D52

This topic was automatically closed 120 days after the last reply. New replies are no longer allowed.