Continue to Site

Welcome to our site!

Electro Tech is an online community (with over 170,000 members) who enjoy talking about and building electronic circuits, projects and gadgets. To participate you need to register. Registration is free. Click here to register now.

  • Welcome to our site! Electro Tech is an online community (with over 170,000 members) who enjoy talking about and building electronic circuits, projects and gadgets. To participate you need to register. Registration is free. Click here to register now.

interfacing lcd jhd162a with at89c51

Status
Not open for further replies.

hiteshmadnani

New Member
i'm have done coding but i want to display my msg for 30 sec and after that the screen should clear and a new msg should be displayed...so what should i do???
and i'm sending u my coding please check it....
DB0 EQU P1.0
DB1 EQU P1.1
DB2 EQU P1.2
DB3 EQU P1.3
DB4 EQU P1.4
DB5 EQU P1.5
DB6 EQU P1.6
DB7 EQU P1.7
EN EQU P3.7
RS EQU P3.6
RW EQU P3.5
DATA EQU P1


WAIT_LCD:
CLR EN ;
CLR RS ;
SETB RW ;
MOV DATA,#0FFh ;
SETB EN ;
MOV A,DATA ;
JB ACC.7,WAIT_LCD ;
CLR EN ;
CLR RW
RET



INIT_LCD:
CLR RS
MOV DATA,#38h
SETB EN
CLR EN
LCALL WAIT_LCD
CLR RS
MOV DATA,#0Eh
SETB EN
CLR EN
LCALL WAIT_LCD
CLR RS
MOV DATA,#06h
SETB EN
CLR EN
LCALL WAIT_LCD
RET



CLEAR_LCD:
CLR RS
MOV DATA,#01h
SETB EN
CLR EN
LCALL WAIT_LCD
RET



WRITE_TEXT:
SETB RS
MOV DATA,A
SETB EN
CLR EN
LCALL WAIT_LCD
RET



LCALL INIT_LCD
LCALL CLEAR_LCD
MOV A,#'R'
LCALL WRITE_TEXT
MOV A,#'O'
LCALL WRITE_TEXT
MOV A,#'O'
LCALL WRITE_TEXT
MOV A,#'M'
LCALL WRITE_TEXT
MOV A,#'.'
LCALL WRITE_TEXT
MOV A,#'N'
LCALL WRITE_TEXT
MOV A,#'O'
LCALL WRITE_TEXT
MOV A,#'.'
LCALL WRITE_TEXT
MOV A,#8CH
LCALL WRITE_TEXT
MOV A,#'3'
LCALL WRITE_TEXT
MOV A,#'0'
LCALL WRITE_TEXT
MOV A,#'1'
LCALL WRITE_TEXT


CLR RS
MOV DATA,#140h
SETB EN
CLR EN
LCALL WAIT_LCD



MOV A,#'M'
LCALL WRITE_TEXT
MOV A,#'r'
LCALL WRITE_TEXT
MOV A,#'.'
LCALL WRITE_TEXT
MOV A,#'S'
LCALL WRITE_TEXT
MOV A,#'U'
LCALL WRITE_TEXT
MOV A,#'R'
LCALL WRITE_TEXT
MOV A,#'A'
LCALL WRITE_TEXT
MOV A,#'N'
LCALL WRITE_TEXT
MOV A,#'J'
LCALL WRITE_TEXT
MOV A,#'I'
LCALL WRITE_TEXT
MOV A,#'T'
LCALL WRITE_TEXT
MOV A,#'K'
LCALL WRITE_TEXT
MOV A,#'O'
LCALL WRITE_TEXT
MOV A,#'S'
LCALL WRITE_TEXT
MOV A,#'T'
LCALL WRITE_TEXT
MOV A,#'A'
LCALL WRITE_TEXT
i want this msg to be displayed foe 20 sec and after that new text will be displayed waht should i right??


LCALL INIT_LCD
LCALL CLEAR_LCD
MOV A,#'R'
LCALL WRITE_TEXT
MOV A,#'O'
LCALL WRITE_TEXT
MOV A,#'O'
LCALL WRITE_TEXT
MOV A,#'M'
LCALL WRITE_TEXT
MOV A,#'.'
LCALL WRITE_TEXT
MOV A,#'N'
LCALL WRITE_TEXT
MOV A,#'O'
LCALL WRITE_TEXT
MOV A,#'.'
LCALL WRITE_TEXT
MOV A,#8CH
LCALL WRITE_TEXT
MOV A,#'3'
LCALL WRITE_TEXT
MOV A,#'0'
LCALL WRITE_TEXT
MOV A,#'2'
LCALL WRITE_TEXT


CLR RS
MOV DATA,#140h
SETB EN
CLR EN
LCALL WAIT_LCD



MOV A,#'M'
LCALL WRITE_TEXT
MOV A,#'r'
LCALL WRITE_TEXT
MOV A,#'.'
LCALL WRITE_TEXT
MOV A,#'M'
LCALL WRITE_TEXT
MOV A,#'A'
LCALL WRITE_TEXT
MOV A,#'N'
LCALL WRITE_TEXT
MOV A,#'I'
LCALL WRITE_TEXT
MOV A,#'S'
LCALL WRITE_TEXT
MOV A,#'H'
LCALL WRITE_TEXT
MOV A,#' '
LCALL WRITE_TEXT
MOV A,#'Y'
LCALL WRITE_TEXT
MOV A,#'A'
LCALL WRITE_TEXT
MOV A,#'D'
LCALL WRITE_TEXT
MOV A,#'A'
LCALL WRITE_TEXT
MOV A,#'V'
LCALL WRITE_TEXT


it will display in this format
ROOM NO.301
Mr.SURANJIT KOSTA
i want thi msg to be display for 30 sec and after this new msg....please help me....
 
here is the code.....in micro c

lcd_delay()
{
int i;
for(i=0;i<10; i++);
}



lcdcommand(unsigned char cmd)
{

rs=0;
P1=cmd;
lcd_delay();
en=1;
lcd_delay();
en=0;
lcd_delay();

}

lcddata(unsigned char dat)
{
rs=1;
P1=dat;
lcd_delay();
en=1;
lcd_delay();
en=0;
lcd_delay();

}

lcdinitialize()
{
rs=0;
en=0;
delay1();

lcdcommand(0x38);
lcdcommand(0x0e); //display on / off
lcdcommand(0x01); //clear lcd display
}

messagedisplay(unsigned char msg[],unsigned char line)
{
int i;
bit skip=0;
if(line==1)
lcdcommand(0x80);
else
lcdcommand(0xc0);
for(i=0;i<=18;i++)
{
if(msg=='\0') skip=1;
if(skip) lcddata(' ');
else
lcddata(msg);
}
}

unsigned char code msg1[] ={" .."};
unsigned char code msg2[] ={" hjkl "};
unsigned char code msg3[] =(" hjghk..");
unsigned char code msg4[] =("hgjkhgjk ");
unsigned char code msg5[] =("hjkghj.. ");
unsigned char code msg6[] =("jkkkk. ");

delay1()
{
long int i;
for(i=0;i<100; i++);
}
 
can u please tell the code for code vision avr(software)...and also the connections of jhd162a with microcontroller
 
hi..
i am a newbie here..
i am trying to interface lcd jhd162A,However i am unable to do it properly
,i want the schematic for its connection with 89c51.
the ports i am using are as follows

1 -gnd
2 -vcc
3-v0 contrast control
4-rs p 2.0
5-rw p2.1
6-e p2.2
7-to 14 d0 to d7 and d7-p3.7
15-5 for back light
16 -gnd


and my code is

// LCD Programming in C **broken link removed**
#include<reg51.h>
#define LCD P3
/* defining commands to run */
unsigned char fset = 0x38; // Function set Interface is 8-bit long
unsigned char Cursor_ON = 0x0E; // Cursor ON/OFF:: 1/0
unsigned char Clear_Lcd = 0x01; // Clear LCD
unsigned char Cursor_Right = 0x06; // cursor movement to right direction
unsigned char Cursor_HOME = 0x02; // Move cursor to home location
unsigned char lin2=0xC0; // Second line address of cursor position
unsigned char lin3=0x94; // Third line address of cursor position
unsigned char lin4=0xD4; // Fourth line address of cursor position

/* line1 to display on LCD */
code unsigned char *line1 = " LCD PROGRAMMING ";
code unsigned char *line2 = " USING C CODE ";

/* defining pins for control signals */
sbit RS = P2^0; /* register select DR/IR: 1/0*/
sbit RW = P2^1; /* read/write: 1/0 */
sbit E = P2^2; /* enable/disable:: 1/0*/
sbit busy = P3^7; /* busy checking bit */

/* signatures of the function being to used*/
void init(void); /* LCD initialization function */
void writeCmd( unsigned char ); /* function to run the commands on LCD*/
void getReady(void); /* function to check either LCD free or in process i.e busy */
void writeString(unsigned char *); /* function to write data/line1 to LCD. geting a pointer parameter.*/


/* start of the main function */
void main(void)
{
for(;;) /*infiniate loop to display repeation */
{
init(); /* call to initialization function*/
writeString(line1); /*sending line1 to lcd by calling writeString() function */
writeCmd(lin2);
writeString(line2); /*sending line1 to lcd by calling writeString() function */

}
}

void init() /* init() function defination. this funcatin sends commnads to the LCD for */
{ /* initialization by calling the writeCmd(unsigned char) function.*/
writeCmd(fset);
writeCmd(Cursor_ON);
writeCmd(Clear_Lcd);
writeCmd(Cursor_Right);
writeCmd(Cursor_HOME);
}

/* function defination for writeCmd(unsigned char) */
void writeCmd(unsigned char cmd)
{
getReady(); /* function for checking either is LCD not busy?*/
E = 0; /* make sure LCD not selected. that not be during initializing process*/
LCD = cmd; /* sending commmand to port3 */
RS = 0; /*Select instruction register*/
RW = 0; /* Write select control */
E = 1;
E = 0;
}

/* Check busy bit7 of the port3: function defination */

void getReady()
{
E = 0; /* make sure lcd is not selected */
busy = 1; /* Make input Bit */
RS = 0; /* Command Register select */
RW = 1; /* Read from LCD */
while (busy == 1)
{
E = 0;
E = 1;
}
E = 1;
}


/* function defination to display data on LCD*/
void writeString(unsigned char *str)
{
unsigned char i;
unsigned int j;
getReady();
E = 0; /* make sure lcd is not selected */
for(i=0;str!='\0';i++)
{
LCD=str;
RS = 1;
RW = 0;
E = 1;
E = 0;
for(j = 0; j<25000; j++);
}
}


i havent got any errors...in simulation but nothng seems to happen on my board..

plz guide me

thanx in advance
 
hello..
i have another query..
i am am unable to write a vcode for a following provblem statement//

problem statement:-

monitor 6 indivisual pins of micro controller 89c51 such that if any pin goes high...The lcd should display a message that corresponding pin is "vacant"

and if the pin goes low the lcd should display "that the pin is engaged"

for ex:p3.1 engaged
p3.2 vacant

thanx in advance
 
Status
Not open for further replies.

Latest threads

Back
Top