Continue to Site

Welcome to EDAboard.com

Welcome to our site! EDAboard.com is an international Electronics Discussion Forum focused on EDA software, circuits, schematics, books, theory, papers, asic, pld, 8051, DSP, Network, RF, Analog Design, PCB, Service Manuals... and a whole lot more! To participate you need to register. Registration is free. Click here to register now.

automatically display character on next line using C for LCD

Status
Not open for further replies.

rameshrai

Full Member level 3
Joined
Aug 16, 2010
Messages
158
Helped
7
Reputation
14
Reaction score
7
Trophy points
1,298
Activity points
2,272
hi,

how to write C program to display character that does not fit in the first line in the second line of a 16x2 LCD?

thanks
 

It depends how you are sending your characters. If you can count them, when you reach the end of the first line, send a cursor position command to the start of the second line. if you are using absolute cursor positioning for each character, if the position is greater than that of the last place on the first line, add the offset of the address of the second line. The line order on most LCD displays is 1,3,2,4 so overlowing the first line will make characters appear on the third line which the LCD controller probably understands even if it doesn't exist on the LCD glass. The offset you add is to make it skip line 3 so the next charcter appears on line 2.

Brian.
 

I am using array for the message,

unsigned char text[] ="This is testing 16x2 HD44780 LCD ";
unsigned char k;

while(1)
{
init_sub();

for (k=0;k<32;k++)
{
if(z <= 16)
lcd_data(text[k]);
else if(z > 16 & z <32)
lcd_data2(text[k]);
}
delay(50);
}

tried to use two subroutine lcd_data and lcd_data2,

can you help?

thanks
 

No need to use two routines but you do need to set the cursor to the start of the second line (DDRAM address 0x40). You can't do that by sending a character to the LCD, you have to send a command.

something like this:
Code:
	k = 0;
	while(k < 32)
	{
		lcd_data(text[k]);
		k++;
		if(k == 16) lcd_command(0xC0); // position cursor at start of second line
	}

I'm assuming you have an equivalent routine to 'lcd_data' called 'lcd_command'.

Brian.
 
Status
Not open for further replies.

Similar threads

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Back
Top