Thursday, 14 November 2024

Interfacing KS0108 based 128×64 Graphical LCD with Arduino

 

Aim:

This tutorial describes how to interface between a 128×64 graphic LCD and an 8-bit
micro-controller. The techniques described here are useful for any other controller type and interfacing technique. The micro-controller is connected via its I/O lines and all signals to the LCD are controlled directly by software.

Description:


Display mapping: Individual pixels can be controlled by writing a byte to a specific address. Each address is mapped to a corresponding set of 8 pixels on the display. Please refer to Figure 1. Note that the order of the columns is reversed. The first byte of data entered after setting the address registers to 0 will appear in the upper right of the display.
The display has 20 pins, numbered from right to left, as we can see in the picture below. It can be used to communicate with the any microcontroller using parallel communication. In this article, where the LCD refresh rate is not a critical point, we will use the parallel communication
The circuit uses a potentiometer (used a 50K) for adjusting the display contrast, and power is made ​​by 5v power supply.
The specification of this LCD are as follows.
  • 128 horizontal pixel and 64 vertical pixel resolution.
  • Controlled based on KS0108B
  • Parallel 8bit interface
  • On board graphic memory.
  • Available in Green backlight with dark green pixels.
  • Also available in Blue backlight with light blue pixels.
  • LED backlight.
  • 20 PIN linear connection.

PIN Description

PIN
Name
Function
Connection with AVR PIN
1VssGround
2Vcc+5v Supply in
3V0Contrast Adjust
4RSInstruction/Data Register SelectA3
5R/WREAD/WRITE SELECTIONA2
6EENABLE SIGNALA4
7DB0DATA IN/OUT8
8DB1DATA IN/OUT9
9DB2DATA IN/OUT10
10DB3DATA IN/OUT11
11DB4DATA IN/OUT4
12DB5DATA IN/OUT5
13DB6DATA IN/OUT6
14DB7DATA IN/OUT7
15CS1Chip Select 1A1
16CS2Chip Select 2A0
17RSTRESET SIGNALRESET
18VEENEGATIVE 10V OUT
19LED+LED BACKLIGHT
20LED-LED BACKLIGHT

Block Diagram

glcd

Schematic



Code

// *******************************************************
// Project: Interfacing Graphical LCD with Arduino
// Author: Hack Projects India
// Module description: Operate Graphical LCD
// *******************************************************

// include the library header
#include <glcd.h>
#include "config/ks0108_Mega.h" // Para Arduino Mega

// include the Fonts
#include <fonts/allFonts.h>

void setup() 
{
  // Initialize the GLCD 
  GLCD.Init();

  // Select the font for the default text area
  GLCD.SelectFont(System5x7);

 GLCD.ClearScreen();
 GLCD.CursorTo(0, 0);
  // GLCD.print("LCD Grafico!");
  //GLCD.print("123456789012345678901");
  GLCD.print("Hack Projects India");
  //delay(3000);
}


void loop() 
{
}

Downloads:

The code was compiled in Keil uvision4 and simulation was made in Proteus v7.7.
To download code and proteus simulation click here.

Further Reading suggestions:


You may also like,

No comments:

Post a Comment