member
Basics: Project 048a LCD 12864B
of Acoptex.com in UNO
Basics: Project 048a
Project name: LCD 12864B
Tags: Arduino, Arduino Uno, LCD 12864, LCD 128x64, LCD 12864 module, Potentiometer, potentiometer, Graphic LCD 12864B, 12864zw, OpenGLCD library, KS0108 Graphics LCD library, u8glib library, LCD12864RSPI library, ST7920 controller, LCD12864 library
Attachments:
Dear visitors. You can support our project buy clicking on the links of parts and buying them or donate us to keep this website alive. Thank you
In this project, you needed these parts :
1.Arduino Uno R3 (you can also use the other version of Arduino)
2.LCD 12864 1pc
3.Arduino IDE ( you can download it from here )
4.Jumper cables F-M
5.Potentiometer 10KOhm 1pc
6. Breadboard 1 pc
7. Momentary switch (button) 2 pcs (optional for Pong Game)
General
In this project, we will learn how to use an LCD12864B with ST7290 controller to display characters and strings. In this project we will use LCD12864B module with 20 header pins
Understanding the potentiometer
See more information about potentiometer here.
Understanding LCD 12864B
The meaning of LCD 12864B marking is graphic Liquid Cristal Display 128x64 pixels with green backlight. The display can be used to output text or graphics.
As we all know, though LCD and some other displays greatly enrich the man-machine interaction, they share a common weakness. When they are connected to a controller, multiple IOs will be occupied of the controller which has no so many outer ports. Also it restricts other functions of the controller.
LCD12864B module have 20 pins and the part of communication: 8 data pins (D0 ~ D7), 5 transmission control pins (D/I, R/W, E, RST, PSB). The other pins: LCD12864 power pins (GND, VCC), backlight power pins (BLA, BLK) and brightness control pins (VO, VOUT). Note: if want to adjust the brightness of LCD12864, you need a 10K ohm variable resistor to connect with VO, VOUT and GND pins.
Block diagram:
Specification:
- Dot Matrix: 128x64
- Driver IC: ST7920
- Interface: 8-bit 6800,8-bit 8080,IIC.
- Weight: 70g
- Controller: ST7920
- Size: 93x70mm
- Wide range of operating temperature: -40°C to 70°C
- Operation Voltage Range: 2.7V to 5.5V
- Support 8-bit, 4-bit and serial bus MPU interface
- 64 x 16-bit display RAM (DDRAM) (Supports 16 words x 4 lines (Max), LCD display range 16 words x 2 lines)
- 64 x 256-bit Graphic Display RAM (GDRAM)
- 2M-bits Character Generation ROM (CGROM):
- Support 8192 Chinese words (16x16 dot matrix)
- 16K-bit half-width Character Generation ROM (HCGROM): Supports 126 characters (16x8 dot matrix)
- 32-common x 64-segment (2 lines of character) LCD drivers
- Automatic power on reset (POR)
- External reset pin (XRESET)
- With the extension segment drivers, the display area can up to 16x2 lines
- Built-in RC oscillator: frequency is adjusted by an external resistor
- Low power consumption design (normal mode (450uA Typ VDD=5V), standby mode (30uA Max VDD=5V))
- VLCD (V0 to VSS): max 7V
- Graphic and character mixed display mode
- Multiple instructions: display clear, return home, display ON/OFF, cursor ON/OFF, display character blink, cursor shift, display shift, vertical line scroll, reverse display (by line), standby mode
- Built-in voltage booster (2 times) VOUT: max 7V
- 1/33 Duty (with ICON)
You can read about LCD12864B module here and here.
LCD driver ST7920
ST7920 LCD controller/driver IC can display alphabets, numbers, Chinese fonts and self-defined characters. It supports 3 kinds of bus interface, namely 8-bit, 4-bit and serial. All functions, including display RAM, Character Generation ROM, LCD display drivers and control circuits are all in a one-chip solution. With a minimum system configuration, a Chinese character display system can be easily achieved. ST7920 includes character ROM with 8192 16x16 dots Chinese fonts and 126 16x8 dots half-width alphanumerical fonts. Besides, it supports 64x256 dots graphic display area for graphic display (GDRAM). Mix-mode display with both character and graphic data is possible. ST7920 has built-in CGRAM and provide 4 sets software programmable 16x16 fonts. ST7920 has wide operating voltage range (2.7V to 5.5V). It also has low power consumption. So ST7920 is suitable for battery-powered portable device.
ST7920 LCD driver consists of 32-common and 64-segment to drive the LCD panel. Company with the extension segment driver (ST7921).ST7920 can support up to 32-common x 256-segment display.
Segment data from CGRAM, CGROM and HCGROM are shifted into the 64 bits segment latche to display. Extended segment driver (ST7921) can be used to extend the segment outputs up to 256 segments. The ST7920 chip supports parallel and synchronized serial interface (SPI) mode. You can choose which mode to use by setting the PSB pin high or low. ST7920 is in serial interface mode when pulling down PSB pin. ST7920 is in parallel mode by pulling up PSB pin.
You can read the ST7920 datasheet here.
Signals and connections of the potentiometer
You can read more about it here.
Signals and connections of the LCD 12864B
GND (or VSS) - Ground. Connect to Arduino board ground pin.
VCC (or VDD)- Power supply. Connect to Arduino board 5V pin
RS (or D/I or DI) - A register select pin that controls where in the LCD’s memory you are writing data to. You can select either the data register, which holds what goes on the screen, or an instruction register, which is where the LCD’s controller looks for instructions on what to do next.
R/W (or RW) - A Read/Write pin to select between reading and writing mode
E (or EN) - An enabling pin that reads the information when High level (1) is received. The instructions are run when the signal changes from High level to Low level.
DB0 - DB7 - Data pins used to read and write data
PSB -Interface selection (LOW - serial mode; HIGH - 8/4-bit parallel bus mode)
NC - NOT IN USE
RST - Reset pin.
VOUT - Negative power output voltage pin to adjust the LCD contrast
V0 - Operating voltage pin to adjust the LCD contrast.
BLA - BLACKLIGHT +5V (Pin to control LCD backlight)
BLK - BLACKLIGHT 0V (Pin to control LCD backlight)
Wiring
Make sure the pins are connected correctly. Otherwise, characters will not be displayed properly.
The following picture shows the needed connections between the LCD 12864 display and the Arduino Uno.
1.Parallel mode. You need most of the pins of Arduino board when using this mode.
LCD12864B pins -> Arduino Uno
BLK GND pin
BLA 5V pin
D0 Digital pin 5
D1 Digital pin 6
D2 Digital pin 7
D3 Digital pin 8
D4 Digital pin 9
D5 Digital pin 10
D6 Digital pin 11
D7 Digital pin 12
PSB 5V pin
E Digital pin 4
R/W Digital pin 3
RS Digital pin 2
VCC 5V pin
GND GND pin
Regulating the contrast of the lcd is normally done with a potentiometer( in our case we have a trimmer on the PCB connected to V0, Vcc and GND – rated 7.5KOhm, you can also adjust contrast with trimmer too) :
VO middle pin of potentiometer
VOUT left pin of potentiometer
GND right pin of potentiometer
To use U8g2 library you need to connect LCD R/W pin to Arduino board GND pin and LCD RST pin to Arduino board analog pin A1.
Wiring for Pong game:
LCD12864B pins -> Arduino Uno
BLK GND pin
BLA 5V pin
D0 Digital pin 5
D1 Digital pin 6
D2 Digital pin 7
D3 Digital pin 8
D4 Digital pin 9
D5 Digital pin 10
D6 Digital pin 11
D7 Digital pin 12
PSB Digital pin 13
E Digital pin 4
R/W Digital pin 3
RS Digital pin 2
VCC 5V pin
GND GND pin
Regulating the contrast of the lcd is normally done with a potentiometer( in our case we have a trimmer on the PCB connected to V0, Vcc and GND – rated 7.5KOhm, you can also adjust contrast with trimmer too) :
VO middle pin of potentiometer
VOUT left pin of potentiometer
GND right pin of potentiometer
Movement control buttons:
Button UP -> Arduino board analog pin A0 and GND pin
Button DOWN-> Arduino board analog pin A1 and GND pin
2.Hardware SPI mode. Using this mode you need only 3 pins (SCK, MOSI and CS) on the Arduino to control the lcd.
LCD12864B pins -> Arduino Uno
BLK GND pin
BLA 5V pin
PSB GND pin
E Digital pin 13 (SCK)
R/W Digital pin 11 (MOSI)
RS Digital pin 10 (CS)
VCC 5V pin
GND GND pin
Regulating the contrast of the lcd is normally done with a potentiometer( in our case we have a trimmer on the PCB connected to V0, Vcc and GND – rated 7.5KOhm, you can also adjust contrast with trimmer too) :
VO middle pin of potentiometer
VOUT left pin of potentiometer
GND right pin of potentiometer
To use U8g2 library you need to connect LCD R/W pin to Arduino board GND pin and LCD Reset pin to Arduino board analog pin A1.
Step by Step instruction
- Plug your Adruino Uno board into your PC and select the correct board and com port
- Verify and upload the the sketch to your Adruino Uno.
- You may need to adjust the potentiometer on breadboard until LCD12864 can display clearly.
Code
Array for your picture can be generated by simply uploading the logo image in the following link or you can use different programs: LCD Assitant, Bitmap2LCD, TheDotFactory , GIMP, Bitmap2Code. You can also create picture in binary format and convert to HEX format using online tool.
1. u8glib library. You can read about it here.This library supports the parallel and SPI mode but is not maintained anymore. We attached quite a lot examples in this project with this library. You need to setup u8g object if you will use different controller just replace U8GLIB_ST7920_128X64 in each sketch with your constructor call. The complete list of supported devices with all constructor calls is here. You can check for you constructor in EXAMPLES directory of U8GLIB library.
2. LCD12864RSPI library. This library supports SPI mode only and is not maintained. By default latch pin RS(CS) - digital pin 10 of Arduino board, data pin RW(SID) - digital pin 11 of Arduino board, clock pin EN(CLK) -digital pin 13 of Arduino board. You can change them in library file LCD12864RSPI.h .
3.OpenGLCD library. You can read about it here. This library is maintained and supports SPI mode, does not work with ST7290 controller.
4.KS0108 Graphics LCD library. You can read about it here and here. This library is not maintained and supports SPI mode, does not work with ST7290 controller.
5.U8g2 library. To use this library you need to connect LCD R/W pin to Arduino board GND pin and LCD Reset pin to Arduino board analog pin A1. It's a monochrome graphics library for embedded devices. You can read about it here. Supports parallel and SPI modes and it is maintained. Supported Display Controller: SSD1305, SSD1306, SSD1309, SSD1322, SSD1325, SSD1327, SSD1329, SSD1606, SSD1607, SH1106, T6963, RA8835, LC7981, PCD8544, PCF8812, UC1601, UC1604, UC1608, UC1610, UC1611, UC1701, ST7565, ST7567, ST7588, ST75256, NT7534, IST3020, ST7920, LD7032, KS0108, SED1520, SBN1661, IL3820, MAX7219 (see here for a full list). U8g2 also includes U8x8 library. Features for U8g2 and U8x8 are:
- Includes all graphics procedures (line/box/circle draw).
- Supports many fonts. (Almost) no restriction on the font height.
- Requires some memory in the microcontroller to render the display.
- Text output only (character) device.
- Only fonts allowed with fixed size per character (8x8 pixel).
- Writes directly to the display. No buffer in the microcontroller required.
6. LCD12864 library. Supports Parallel mode only. You can read about it here. The pins are set in file LCD12864.h of this library. With this library you can draw lines, draw rectangles, draw filled rectangles, draw circles, animation, draw bitmaps, ASCII (switch from graphics to ASCII).
7. LCD12864R library. Supports Parallel mode only. This library is a modification of previous library. The pins are set in file LCD12864.h of this library.
Summary
We have learnt how to use an LCD12864B with ST7290 controller to display characters and strings.
Libraries
- See attachments on the begining of this project description.
- u8glib library. Download, unzip and add to libraries in our PC, for example C:\Users\toshiba\Documents\Arduino\libraries. This link you can find in Preferences of Adruino IDE program which installed in your PC.
- LCD12864RSPI library. Download, unzip and add to libraries in our PC, for example C:\Users\toshiba\Documents\Arduino\libraries. This link you can find in Preferences of Adruino IDE program which installed in your PC.
- U8g2 library. Download, unzip and add to libraries in our PC, for example C:\Users\toshiba\Documents\Arduino\libraries. This link you can find in Preferences of Adruino IDE program which installed in your PC.
- LCD12864 library. Download, unzip and add to libraries in our PC, for example C:\Users\toshiba\Documents\Arduino\libraries. This link you can find in Preferences of Adruino IDE program which installed in your PC.
- LCD12864R library. Download, unzip and add to libraries in our PC, for example C:\Users\toshiba\Documents\Arduino\libraries. This link you can find in Preferences of Adruino IDE program which installed in your PC.
Sketch
- See attachment on the beginning of this project description.
Other projects of Acoptex.com










jobs.viewed