Serial LCD interface with Arduino Mega


I got a robotbase 12864 LCD based on ST7920 controller.

I want to connect it with Mega 1280 And to test some example.

Please suggest wiring with Mega 1280 for serial LCD.

Also example code.


Please suggest wiring with Mega 1280 for serial LCD.

There are three wires. One is for +5V. One is for ground. The other connects to a hardware or software serial pin. Since the Mega has 4 hardware serial ports, use one of them.

Also example code.

SerialN.print("That was easy"); // Where N corresponds to the serial port being used.

thanks for the reply.

The info I got from the vendor.

When operating in serial mode pin definition:
PIN1 ------ GND power - generally take 0V.
PIN2 ------ Power +, general access 5V.
PIN3 ------ contrast adjustment side.
PIN4 ------ RS (CS), chip select
PIN5 ------ R / W (SID), the data
PIN6 ------ E (SCK), pulse
PIN7 ------ NC, not connected
PIN8 ------ NC, not connected
PIN9 ------ NC, not connected
PIN10 ----- NC, not connected
PIN11 ----- NC, not connected
PIN12 ----- NC, not connected
PIN13 ----- NC, not connected
PIN14 ----- NC, not connected
PIN15 ----- PSB parallel: PSB = 1, can take VCC; Serial: PSB = 0, general access GND
PIN16 ---- NC, not connected
PIN17 ----- ~ RST, reset the module, do not connect
PIN18 ---- NC, not connected
PIN19 ---- LED, backlight +, general access 5V.
PIN20 ---- LED-, back light -, general access GND.

PIN 4,5,6 are important.

So where these PIN 4,5,6 can be connected in mega?

I feel its not just serial comm, some command and initialization is needed.


Why don't you post a link to the device that you have?

Serial LCDs have 3 lines. The lines that the vendor is suggesting that you connect suggest that the device uses SPI, not serial, communications. A link would be useful to see for certain.

the product.



The LCD supposed to be connected in the serial interface.

See the image bellow.

Now if I have to connect to the mega 1280, which pins I can use?

Any code available?


You can either use SPI which are pins 50-53 or use shiftOut which can use any pins. Download the ST7920 datasheet from Sitronix to get the programming instructions to initialize it.