4 Bit LCD
4 Bit LCD
4 Bit LCD
mCard MICROPROCESSOR PRESENTATIONS EMBEDDED LINUX NEWS TUTORIALS / ARTICLES CODE BANK QUERY ABOUT US FAQ
INFOLETTER
In the recent years LCD, is finding in daily use replacing LEDs which may be Single, Seven Segment or Multi Segment LEDs Because of Declining Pricing of LCD and ability to display numbers, characters and graphics. Another advantage of LCD is that, Incorporation of refreshing controller in to LCD for relieving the CPU of the task of refreshing LCD. Download Code (KEIL Project) (Zip Format)
Digital Oscilloscopes Digital Oscilloscopes now from Rohde&Schwarz. Get Details Here! www.scope-of-the-art.com/RTO Embedded Microcontroller Search Thousands of Catalogs for Embedded Microcontroller www.globalspec.com Custom and Std LCDs Get the best LCD solutions from us Fast, efficient, delightful service
www.crystalimage-lcd.com
Circuit
Pic of circuit
Symbol
Vss Vcc Vee
I/O
-
Description
Ground +5V
Contrast Control
Input
Command/Data Register Read/Write Register Enable Not Used in 4-Bit Mode Not Used in 4-Bit Mode Not Used in 4-Bit Mode Not Used in 4-Bit Mode Data Bus in 4-Bit Mode Data Bus in 4-Bit Mode Data Bus in 4-Bit Mode Data Bus in 4-Bit Mode For LCD Back Light For LCD Back Light
Input Input/Output Input/Output Input/Output Input/Output Input/Output Input/Output Input/Output Input/Output Input/Output
-
Flow Chart
Code in C
#include<reg51.h> #include<stdio.h> #define LCDPORT P2 sbit RS=LCDPORT^0; sbit RW=LCDPORT^1; sbit E =LCDPORT^2; bit status=0; #define lcd_delay 400 /* * * * Function Name Input Output : delay
: :
value None
* */
Description
void delay(unsigned int j) { unsigned int i=0; for(i=0;i<j;i++); } /* * Function Name * Input * Output * Description */
: :
void lcd_init_write(unsigned char a) { RS=0; RW=0; LCDPORT=a; E=1; delay(lcd_delay); E=0; } /* * Function Name : lcd_com * Input : value * Output : None * Description : For Sending Commands and Data by checking Status Bit */ void lcd_com(unsigned char a) { unsigned char temp; if(status) { status=0; goto next; } RS=0; next: RW=0; temp=a; temp&=0xf0; LCDPORT&=0x0f; LCDPORT|=temp; E=1; delay(lcd_delay); E=0; temp=a<<4; temp&=0xf0; LCDPORT&=0x0f; LCDPORT|=temp; E=1; delay(lcd_delay); E=0; } /* * Function Name : * Input * Output * Description */
// Mask Lower 4 Bits // Make No Affect on 0ther Port Pins // Send Higher Nibble to LCDPORT //Send Enable Signal to LCD //Left Shift Byte Four Times // Mask Higher 4 Bits // Make No Affect on 0ther Port Pins // Send Lower Nibble to LCDPORT // Send Enable Signal to LCD
: :
void lcd_data(unsigned char a) { status=1; RS=1; lcd_com(a); } /* * Function Name : lcd_init * Input : None * Output : None * Description : For Intilization LCD in 4-Bit Mode */ void lcd_init(void) { delay(lcd_delay); lcd_init_write(0x30); //Special Sequence:Write Function Set. delay(lcd_delay); lcd_init_write(0x30); //Special Sequence:Write Function Set. delay(lcd_delay); lcd_init_write(0x30); //Special Sequence:Write Function Set. delay(lcd_delay); lcd_init_write(0x20); // 0x20 for 4-bit delay(lcd_delay); lcd_com(0x28); //Display Off, Cursor Off, Blink Off delay(lcd_delay); lcd_com(4); // Clear Screen & Returns the Cursor Home delay(lcd_delay); lcd_com(0x85); delay(lcd_delay); lcd_com(6); //Inc cursor to the right when writing and dont shift screen delay(lcd_delay);
} /* * Function Name * Input * Output * Description */ void lcd_puts(char *str) { unsigned int i=0; for(;str[i]!=0;i++) lcd_data(str[i]); } /* * Function Name * Input Output * Description */
lcd_com(1); delay(lcd_delay);
: :
: :
: :
: :
void main() { lcd_init(); //Intilize LCD in 4-Bit Mode lcd_com(0X80); // Start Cursor From First Line lcd_puts("Hello"); //Print HELLO on LCD lcd_com(0XC0); // Start Cursor From Second Line lcd_puts("World"); //Print HELLO on LCD while(1); //Stay Forever Here }
[Home] [Query] [FAQ] [Aboutus] [Contact us] [Sitemap] [Privacy Policy] [Advertise ]
RSS FEED
Logos and brand names used in this site are belonging to their respected ow ners. We have used them here only for the purpose of information. Enable Active X control from internet options of internet explorer to view all element of this site.