#include<reg52.h>
#include<stdio.h>
#include<intrins.h>
sbit RS = P2^0; // Register Select line
sbit RW = P2^1; // Read/write line
sbit Enable = P2^2; // Enable line
#define LCD_PORT P0 // define port
LCD function prototypes
void send_cmd(unsigned char);
void send_data(unsigned char*);
void send_char(unsigned char);
void LCD_init(void);
void delayms(unsigned int);
Main Funciton declaration
void main()
{
LCD_PORT = 0x00; // Make the port as output port
LCD_init(); // LCD initialization
while(1)
{
send_cmd(0x83); // Force cursor to beginning of 1st line, if the number is 0x83 then force the cursor to 53rd position
delayms(100); // Delay of 100millisec
send_data("fantasyelectronisc"); // Send data string
delayms(500); // Delay of 0.5sec
send_cmd(0xC0); // Force cursor to beginning of 2nd line
delayms(100); // Delay of 100millisec
send_data(" http://fantasyelectronisc.blogspot.in/ "); // send data string
delayms(500); // Delay of 0.5sec
send_cmd(0x01); // Clear display
delayms(100); // Delay of 100millisec
send_cmd(0x80); // Force cursor to beginning of 1st line
delayms(100); // Delay of 100millisec
send_char('A'); // testing send_char position
delayms(500); // Delay of 0.5sec
send_cmd(0x01); // Clear display
delayms(100); // Delay of 100millisec
}
}
LCD Initialization Function declaration
void LCD_init()
{
send_cmd(0x38); // configuring LCD as 2 line 5x7 matrix
send_cmd(0x0E); // Display on, Cursor blinking
send_cmd(0x01); // Clear Display Screen
send_cmd(0x06); // Increment Cursor (Right side)
}
void send_char(unsigned char character)
{
LCD_PORT = character;
RS = 1; // Select Data Register
RW = 0; // write operation
Enable = 1; // High to Low pulse provided on the enable pin with nearly 1ms(>450ns)
delayms(1); // 1 millisec delay
Enable = 0;
delayms(100); // 100 millisec delay
}
LCD Command Sending Function declaration
void send_cmd(unsigned char Command)
{
LCD_PORT = Command;
RS = 0; // Select Command Register
RW = 0; // write operation
Enable = 1; // High to Low pulse provided on the enable pin with nearly 1ms(>450ns)
delayms(1); // 1 millisec delay
Enable = 0;
}
LCD data sending Function declaration
void send_data(unsigned char *String)
{
unsigned char i=0;
while(String[i]!='\0')
{
LCD_PORT = String[i++];
RS = 1; // Select Data Register
RW = 0; // write operation
Enable = 1; // High to Low pulse provided on the enable pin with nearly 1ms(>450ns)
delayms(1); // 1 millisec delay
Enable = 0;
if(i>=16) // If the number of characters in the string > 16, then the below command automatically
send_cmd(0x1C); // Shift the display right side
delayms(100); // 100 millisec delay
}
}
delayms Function declaration
void delayms(unsigned int val)
{
unsigned int i,j;
for(i=0;i<=val;i++)
{
for(j=0;j<=100;j++)
_nop_(); // no operation produce 1us time delay
}
}
#include<stdio.h>
#include<intrins.h>
sbit RS = P2^0; // Register Select line
sbit RW = P2^1; // Read/write line
sbit Enable = P2^2; // Enable line
#define LCD_PORT P0 // define port
LCD function prototypes
void send_cmd(unsigned char);
void send_data(unsigned char*);
void send_char(unsigned char);
void LCD_init(void);
void delayms(unsigned int);
Main Funciton declaration
void main()
{
LCD_PORT = 0x00; // Make the port as output port
LCD_init(); // LCD initialization
while(1)
{
send_cmd(0x83); // Force cursor to beginning of 1st line, if the number is 0x83 then force the cursor to 53rd position
delayms(100); // Delay of 100millisec
send_data("fantasyelectronisc"); // Send data string
delayms(500); // Delay of 0.5sec
send_cmd(0xC0); // Force cursor to beginning of 2nd line
delayms(100); // Delay of 100millisec
send_data(" http://fantasyelectronisc.blogspot.in/ "); // send data string
delayms(500); // Delay of 0.5sec
send_cmd(0x01); // Clear display
delayms(100); // Delay of 100millisec
send_cmd(0x80); // Force cursor to beginning of 1st line
delayms(100); // Delay of 100millisec
send_char('A'); // testing send_char position
delayms(500); // Delay of 0.5sec
send_cmd(0x01); // Clear display
delayms(100); // Delay of 100millisec
}
}
LCD Initialization Function declaration
void LCD_init()
{
send_cmd(0x38); // configuring LCD as 2 line 5x7 matrix
send_cmd(0x0E); // Display on, Cursor blinking
send_cmd(0x01); // Clear Display Screen
send_cmd(0x06); // Increment Cursor (Right side)
}
void send_char(unsigned char character)
{
LCD_PORT = character;
RS = 1; // Select Data Register
RW = 0; // write operation
Enable = 1; // High to Low pulse provided on the enable pin with nearly 1ms(>450ns)
delayms(1); // 1 millisec delay
Enable = 0;
delayms(100); // 100 millisec delay
}
LCD Command Sending Function declaration
void send_cmd(unsigned char Command)
{
LCD_PORT = Command;
RS = 0; // Select Command Register
RW = 0; // write operation
Enable = 1; // High to Low pulse provided on the enable pin with nearly 1ms(>450ns)
delayms(1); // 1 millisec delay
Enable = 0;
}
LCD data sending Function declaration
void send_data(unsigned char *String)
{
unsigned char i=0;
while(String[i]!='\0')
{
LCD_PORT = String[i++];
RS = 1; // Select Data Register
RW = 0; // write operation
Enable = 1; // High to Low pulse provided on the enable pin with nearly 1ms(>450ns)
delayms(1); // 1 millisec delay
Enable = 0;
if(i>=16) // If the number of characters in the string > 16, then the below command automatically
send_cmd(0x1C); // Shift the display right side
delayms(100); // 100 millisec delay
}
}
delayms Function declaration
void delayms(unsigned int val)
{
unsigned int i,j;
for(i=0;i<=val;i++)
No comments:
Post a Comment