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.

How to make LCD texts to move either to the right or the left?

Status
Not open for further replies.

caramelz

Junior Member level 2
Joined
Jul 19, 2012
Messages
22
Helped
0
Reputation
0
Reaction score
0
Trophy points
1,281
Activity points
1,464
Hi guys. I want to make text in LCD to move around. i know is about shifting but due to my poor skills in microcontroller, i not able to do so. Please help.
here is the code i'm having.



#include <p18f4520.h>
#include <delays.h>

void Init_LCD(void); //Initialise the LCD
void W_ctr_8bit(char); //8-bit Control word for LCD
void W_data_8bit(char); //8-bit Text Data for LCD

#define LCD_DATA PORTD
#define LCD_RS PORTBbits.RB1
#define LCD_E PORTBbits.RB2

unsigned char LCD_TEMP,i,j,k,m;
char MESS[8]="welcome";

void main()
{
ADCON1=0x0f;
TRISB=0b11111001; // Port D as LCD data output
TRISD=0b00000000;
Init_LCD();
for(i=0;i<7;i++)
W_data_8bit(MESS);
}
/* LCD display initialization */
void Init_LCD()
{
W_ctr_8bit (0b00111000); //Function Set - 8-bit, 2 lines, 5x7
W_ctr_8bit (0b00001100); //Display on, cursor on
W_ctr_8bit (0b00000110); //Entry mode - inc addr, no shift
W_ctr_8bit (0b00000001); //Clear display
W_ctr_8bit (0b00000010); //Return cursor to home position
}


/* Write control word to LCD */
void W_ctr_8bit(char x)
{
LCD_RS = 0; //Logic '0'
LCD_E = 1; //Logic '1'
LCD_DATA= x;
LCD_E = 0; //Logic '0'
Delay10TCYx(50); //1ms delay
}

/* Write text data to LCD */
void W_data_8bit(char x)
{
LCD_RS = 1; //Logic '1'
LCD_E = 1; //Logic '1'
LCD_DATA = x;
LCD_E = 0; //Logic '0'
Delay10TCYx(50); //1ms delay
}
 

Which Compiler are you using? It is very easy with mikroE Compilers. For other Compilers you have to write Code. Left/Right Shift shifts all the lines of LCD. If you want to shift line 1 text then after it shifts both lines restore the second line to earlier text.

I am working on that code. If I succeed I will post the code.
 

Which Compiler are you using? It is very easy with mikroE Compilers. For other Compilers you have to write Code. Left/Right Shift shifts all the lines of LCD. If you want to shift line 1 text then after it shifts both lines restore the second line to earlier text.

I am working on that code. If I succeed I will post the code.

i'm using MCC18
 

If your LCD is HD44780 compliant then you should be able to issue the "shift left" (0x18) and "shift right" (0x1C) commands.
 

Status
Not open for further replies.

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Back
Top