Displaying Large / Big Fonts on character LCD using Arduino
Normally, a character LCD has 8×5 dots character size, but this library allows you to combine two rows to make larger fonts using the same 8×5 dots character LCD, this library can work on different sizes including 16×2, 20×2, 16×4 and 20×4 Character LCDs, using the 4 bits data bus.
The Library given above has all same commands of “LiquidCrystal.h” Library, except few additional commands, like:
render_big_msg("text",x,y);
whereas:
text = any 4 letter text to display on LCD (Big fonts)
x = Horizontal Position (0 is starting position)
y = Vertical Position (0 is Vertically Centered)
invert_big_font(inverted);
where as:
inverted = boolean (true/ false)
if inverter=true then all fonts using render_big_msg(“text”,x,y); command will be inverted.
All other LCD commands like setCursor, clear etc are same.
The code and connection diagram given below is also compatible with any character LCD, whether it is 16×2, 16×4, 20×2, 20×4 etc., In code, you just have to edit.
lcd.begin(16, 2);
LCD Pinouts:
Connections:
Character LCD has 16 terminals:
LCD | Arduino |
1 – VSS | GND |
2 – VCC | +5v |
3 – VEE | Potentiometer |
4 – RS | 2 |
5 – R/W | GND |
6 – EN | 3 |
7 – DB0 | N.C |
8 – DB1 | N.C |
9 – DB2 | N.C |
10 – DB3 | N.C |
11 – DB4 | 8 |
12 – DB5 | 9 |
13 – DB6 | 10 |
14 – DB7 | 11 |
15 – LED+ | +5v |
16 – LED- | GND |
Code:
#define phi_2_shield // Define this if you are using the phi 2 shield #include <liquidcrystal.h> #include <stdio.h> #include <avr/pgmspace.h> #include <phi_big_font.h> #include "defs.h" LiquidCrystal lcd(2,3,8,9,10,11); // Create the lcd object byte img1[]={ 0,0,3,3,4,4,4,3,3,0,0,0,3,3,4,4,4,3,3,0, 0,6,1,4,4,7,4,4,1,6,4,6,1,4,4,4,4,4,1,6, 0,3,4,1,1,7,1,1,4,3,1,3,4,1,1,1,1,1,4,3, 0,0,6,6,1,1,1,6,6,0,0,0,6,6,1,1,1,6,6,0 };// line 0, 2, 1, 3 order. boolean inverted=false; void setup() { lcd.begin(16, 2); init_big_font(&lcd); render_big_msg("c2e",2,0); delay(5000); } void loop() { demo_16X2(); } void demo_16X2() //Asks you for password for a given number of trials { char msg[4]; lcd_clear(); render_big_msg("Big", 0,0); delay(2000); render_big_msg("Font", 0,0); delay(2000); inverted=!inverted; invert_big_font(inverted); lcd_clear(); render_big_msg("Big", 0,0); delay(2000); render_big_msg("Font", 0,0); delay(2000); inverted=!inverted; invert_big_font(inverted); char msg1[]="HI"; byte x=0; byte j=0; render_big_msg(msg1,3,0); delay(1000); // Show messages inside PROGMEM lcd_clear(); for (byte i=0;i<7;i++) { big_msg_lcd(dow_00+i*4, 0,0); lcd.setCursor(13,0); msg_lcd(dow_00+i*4); delay(1000); } for (byte i=0;i<12;i++) { big_msg_lcd(month_00+i*4,0,0); lcd.setCursor(13,0); msg_lcd(month_00+i*4); delay(1000); } // Display numbers lcd_clear(); for (byte i=0;i<20;i++) { lcd.setCursor(0,0); render_big_number(i,0,0); delay(400-i*6); } lcd_clear(); render_big_msg("Big",0,0); delay(2000); render_big_msg("0To9",0,0); delay(2000); // Show all numbers lcd_clear(); for (byte i='0';i<='9';i++) { if (!((i-'0')%4)) lcd_clear(); render_big_char(i,(i-'0')%4*4, 0); lcd.setCursor(15,0); lcd.write(i); delay(500); } delay(1000); // Show all characters lcd_clear(); render_big_msg("Big",0,0); delay(2000); render_big_msg("ATOZ",0,0); delay(2000); lcd_clear(); for (byte i='A';i<='Z';i++) { if (!((i-'A')%4)) lcd_clear(); render_big_char(i,(i-'A')%4*4, 0); lcd.setCursor(15,0); lcd.write(i); delay(500); } delay(1000); lcd_clear(); render_big_msg("Big",0,0); delay(2000); render_big_msg("atoz",0,0); delay(2000); lcd_clear(); for (byte i='a';i<='z';i++) { if (!((i-'a')%4)) lcd_clear(); render_big_char(i,(i-'a')%4*4, 0); lcd.setCursor(15,0); lcd.write(i); delay(500); } delay(1000); // Invert display polarity for the next loop. inverted=!inverted; invert_big_font(inverted); } //Utility functions void msg_lcd(char* msg_line) { char msg_buffer[17]; strcpy_P(msg_buffer,msg_line); lcd.print(msg_buffer); } void show_arduino() { display_img(img1); delay(5000); }
Video on Displaying Large (Big) Fonts on 16×2 Character LCD using Arduino:
Downloads:
This article was earlier posted on comm2excel.com but it is now offline, hence re-posted here.
Related Links:
- Increasing the length of Serial Buffer in Arduino
- Interfacing Water Flow Sensor with Arduino
- Reset Arduino using Programming
- Downloading a webpage from internet using Arduino
- Fetching Google Search using MATLAB
- Interfacing MPL3115A2 Altitude Sensor with Arduino UNO/ Mega
- Errors in Simulating AVR ADC codes on Proteus
- Interfacing Soil Moisture Sensor with Arduino
- Interfacing GPS Shield for Arduino(ublox NEO-6M-0-001) with Arduino Mega 2560
- Interfacing Accelerometer ADXL345 (GY-291) with Arduino UNO/ Mega