DISPLAY HINDI OR CUSTOM CHARACTER ON LCD 16X2 USING ARDUINO

Earlier we learn how to display English letters or ASCII codes (defined for characters) on LCD 16×2.  But now we will learn how to display Hindi or custom characters on LCD 16×2 using Arduino (regional language) like Hindi letters or degree symbols or smiley ☺etc.

Before we begin we first need to understand some concepts
  • First of all, we know LCD 16×2 can display 32 characters on the screen but each character space has a predefined pixel dimension of 5×8, where 5 refers to vertical lines (5 columns) and 8 refers to horizontal lines (8 rows).
pixel dimension of LCD 16x2 5x8
Pixel Dimension of LCD 16×2 is 5×8
  • Secondly, there are 8 location presents on the LCD controller where a custom character can be stored. That means we can store a maximum of 8 characters at a time.
  • To display a custom character we need to design that character on a display matrix of 5×8 and to generate a binary or hex code corresponding to that.
  • We need 8 byte code for one custom-character/letter (each byte contains 8 bit). See the diagram below to understand it more or visit this URLhttps://www.riyas.org/2013/12/online-led-matrix-font-generator-with.html” to generate code for any pattern:

PATTERN CODE GENERATOR

The first row makes first byte code i.e. “byte 0” then the second row makes second byte i.e. “byte 1”, and so on up for 8 bytes.

This is a 5×8 led pattern generator matrix.

LCD pattern generator 5x8
LCD pattern generator matrix 5×8

For the first byte, in row 1 all LEDs are marked HIGH that means all are 1’s which makes the binary number as “11111” (byte contains 8 bit we will consider them as 0 before the number as this does not make any difference). Decimal number of Binary 11111 is 31 and hexadecimal is 1F.

DISPLAY HINDI OR CUSTOM CHARACTER ON LCD 16X2 USING ARDUINO
LCD pattern generator 5×8 First line byte code

Following the same process generates 8 byte code.

For the second byte in row 2, only a single LED is marked that means only that makes 1’s, it makes the binary number as “00100”.

For the third byte in row 3, three LEDs are marked; that means three LEDs make 1’s, which makes the binary number as “01110.

For fourth byte 10101

For fifth byte 01101

For sixth byte 00100

For seventh byte 00100

For eighth byte 00000

In short, which are marked or high are considered as 1, and which are unmarked or low are considered as 0.

Note: Red dot shows led are ON to generate pattern & white are OFF.

LCD pattern generator 5x8 eight lines byte code
LCD pattern generator 5×8 eight lines byte code
  • After generating binary values, we send address location either 64 or 72 or 80 etc. for the first symbol to command register of LCD then we send bitmap value to the LCD data register to get stored in that space. Similarly, other characters can be stored of sizes up to (8 bytes). The location of the next space is apart by 8-byte space.

The symbol locations with their base addresses are given below:

 

S.N.

Symbol Code

Base Address

1.

Symbol  [0]

64

2.

Symbol  [1]

72

3.

Symbol  [2]

80

4.

Symbol  [3]

88

5.

Symbol  [4]

96

6.

Symbol  [5]

104

7.

Symbol  [6]

112

8.

Symbol  [7]

120

 Symbol locations with base addresses in ROM

ARDUINO CODE TO DISPLAY HINDI OR CUSTOM CHARACTER ON LCD 16X2 USING ARDUINO

The symbol locations with their base addresses are given below:

#include <LiquidCrystal.h>
LiquidCrystal lcd(2, 3, 4, 5, 6, 7);

// generating hindi ‘क’ using hexadecimal value
byte hindi_k[8] = {
  0x1F, 0x04, 0x0E, 0x15, 0x0D, 0x04, 0x04, 0x00,
};

// generating smiley using binary value
byte smiley[8] = {
  B00000,
  B10001,
  B00000,
  B00000,
  B10001,
  B01110,
  B00000,
};

void setup( ) {

  /* It is important to use createChar() first before lcd.begin() then only it will work properly*/
  lcd.createChar(0, hindi_k);
  lcd.createChar(1, smiley);

  lcd.begin(16, 2);
  lcd.write(byte(0));
  lcd.write(byte(1));
  delay(1000);
}

void loop( ) {

}

OUTPUT

DISPLAY HINDI OR CUSTOM CHARACTER ON LCD 16X2 USING ARDUINO


READ NEXT
4 BIT MODE & 8 BIT MODE OF LCD 16×2


Total Visits: 2114
0 0 vote
Article Rating
Subscribe
Notify of
guest
0 Comments
Inline Feedbacks
View all comments
0
Would love your thoughts, please comment.x
()
x