Rizwanishaq
Junior Member level 3
I have given all the files now add to the library and give me the response is it good or not
you only need to add header file LCD.h that is at the end of the code
then u can use LCDinitialize(),Clearlcd(),and the printLCD(buff);
//////////////////////////////////////////////////////////////////////////////////////
/////////////////////////////This is provided by the Rizwan Ishaq///////////////
///////////////////// Comsats IIT Wah Campus Pakistan /////////////////////
///////////////////////////// Computer Engineer ///////////////////
/////////////////////////////////////////////////////////////////////////////////////
//This code print the character on the LCD module
//You can use this code to your code without any detail of the LCD
//
#include "LCD.h"
void main()
{
Lcdinitialize(); //Initialize the LCD
Clearlcd(); //Clear the LCD
printLCD("AaBbCc"); // printLCD(buff)
while(1);
}
//////////////////////////////////////////////////////////////////////////////////////
//////////////////////////////////////////////////////////////////////////////////////
#include "LCD.h"
/////////////////////////////////////////////////////////////////////
//////////////////////////Write command routine//////////////////////
void wrcmd(unsigned char cbyte)
{
P1_6=0; //RW
P1_5=0; //RS
P0=cbyte;
P1_7=0; //EN
P1_7=1; //EN
delay();
}
/////////////////////////////////////////////////////////////////////
////////////////////////Write character routine//////////////////////
void wrchar(unsigned char dbyte)
{
P1_6=0; //RW
P1_5=1; //RS
P0=dbyte;
P1_7=1; //EN
P1_7=0; //EN
delay();
}
/////////////////////////////////////////////////////////////////////
////////////////////////Lcd initialization routine///////////////////
void Lcdinitialize()
{
wrcmd(0x38); //Function set (8-bit interface, 2 lines, 5*7 Pixels)
wrcmd(0x10); //Move cursor one character left
wrcmd(0x06); //Character Entery mode
wrcmd(0x0F); //Turn on visible blinking-block cursor
wrcmd(0x03); //Display and cursor
}
/////////////////////////////////////////////////////////////////////
//////////////////////////////Clear LCD routine//////////////////////
void Clearlcd()
{
wrcmd(0x01); //Clear Screen
}
/////////////////////////////////////////////////////////////////////
////////////////////////////////Delay routine////////////////////////
void delay()
{
int i;
for(i=0;i<=5000;i++)
{;}
}
/////////////////////////////////////////////////////////////////////
//////////////////////////PrintLCD Routine///////////////////////////
printLCD(unsigned char *buff)
{
while(*buff)
{
wrchar(*buff);
buff++;
}
}
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
///////////////////////////////////Header file LCD.h//////////////////////////////////////
#include <at89x51.h>
#include<math.h>
#include<stdio.h>
void wrcmd(unsigned char cbyte);
void wrchar(unsigned char dbyte);
printLCD(unsigned char *buff);
void Lcdinitialize();
void Clearlcd();
void delay();
////////////////////////////////////////////////////////////////////////////////////////
you only need to add header file LCD.h that is at the end of the code
then u can use LCDinitialize(),Clearlcd(),and the printLCD(buff);
//////////////////////////////////////////////////////////////////////////////////////
/////////////////////////////This is provided by the Rizwan Ishaq///////////////
///////////////////// Comsats IIT Wah Campus Pakistan /////////////////////
///////////////////////////// Computer Engineer ///////////////////
/////////////////////////////////////////////////////////////////////////////////////
//This code print the character on the LCD module
//You can use this code to your code without any detail of the LCD
//
#include "LCD.h"
void main()
{
Lcdinitialize(); //Initialize the LCD
Clearlcd(); //Clear the LCD
printLCD("AaBbCc"); // printLCD(buff)
while(1);
}
//////////////////////////////////////////////////////////////////////////////////////
//////////////////////////////////////////////////////////////////////////////////////
#include "LCD.h"
/////////////////////////////////////////////////////////////////////
//////////////////////////Write command routine//////////////////////
void wrcmd(unsigned char cbyte)
{
P1_6=0; //RW
P1_5=0; //RS
P0=cbyte;
P1_7=0; //EN
P1_7=1; //EN
delay();
}
/////////////////////////////////////////////////////////////////////
////////////////////////Write character routine//////////////////////
void wrchar(unsigned char dbyte)
{
P1_6=0; //RW
P1_5=1; //RS
P0=dbyte;
P1_7=1; //EN
P1_7=0; //EN
delay();
}
/////////////////////////////////////////////////////////////////////
////////////////////////Lcd initialization routine///////////////////
void Lcdinitialize()
{
wrcmd(0x38); //Function set (8-bit interface, 2 lines, 5*7 Pixels)
wrcmd(0x10); //Move cursor one character left
wrcmd(0x06); //Character Entery mode
wrcmd(0x0F); //Turn on visible blinking-block cursor
wrcmd(0x03); //Display and cursor
}
/////////////////////////////////////////////////////////////////////
//////////////////////////////Clear LCD routine//////////////////////
void Clearlcd()
{
wrcmd(0x01); //Clear Screen
}
/////////////////////////////////////////////////////////////////////
////////////////////////////////Delay routine////////////////////////
void delay()
{
int i;
for(i=0;i<=5000;i++)
{;}
}
/////////////////////////////////////////////////////////////////////
//////////////////////////PrintLCD Routine///////////////////////////
printLCD(unsigned char *buff)
{
while(*buff)
{
wrchar(*buff);
buff++;
}
}
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
///////////////////////////////////Header file LCD.h//////////////////////////////////////
#include <at89x51.h>
#include<math.h>
#include<stdio.h>
void wrcmd(unsigned char cbyte);
void wrchar(unsigned char dbyte);
printLCD(unsigned char *buff);
void Lcdinitialize();
void Clearlcd();
void delay();
////////////////////////////////////////////////////////////////////////////////////////