I have tried it but not getting what i want to display on screen
C:
int main(void)
{
LCD_init();
string ();
while (1)
{
}
}
what I didn't mention ? Have you read post #12 and #14. there is all information
I want write program for LCD on a 8051. I want to see the string "hello friend " on my LCD screen
this is program
C:
#include<reg51.h>
#define port P1 /* Data pins connected to port P1 */
sbit RS = P2^0; /* RS pin connected to pin 0 of port P2 */
sbit RW = P2^1; /* RW pin connected to pin 1 of port P2 */
sbit EN = P2^2; /* EN pin connected to pin 2 of port P2 */
void Delay(unsigned int wait)
{
unsigned i,j ;
for(i=0;i<wait;i++)
for(j=0;j<1200;j++);
}
/* Function to send command instruction to LCD */
void LCD_Command(unsigned char cmd)
{
port = cmd;
RS=0;
RW=0;
EN=1;
Delay(2);
EN=0;
}
/*Function to send display dato LCD */
void LCD_Data(unsigned char Data)
{
port = Data;
RS=1;
RW=0;
EN=1;
Delay(2);
EN=0;
}
/* function for delay */
/* Function to prepare the LCD */
void LCD_init()
{
LCD_Command(0x38);
Delay(20);
LCD_Command(0x0f);
Delay(20);
LCD_Command(0x01);
Delay(20);
LCD_Command(0x81);
Delay(20);
}
void string (void)
{
unsigned int i=0;
unsigned char string[15]= "Hello Friend's";
for(i=0; i<15; i++)
{
LCD_Data(string[i]);
}
}
int main(void)
{
LCD_init();
string ();
while (1)
{
}
}
message on screen
message should be print on first row and it should be fixed
I've read the entire several times thread. You need to tell us EXACTLY what you want and exactly what you're getting when it's not what you want. More than once, you've provided code that you said didn't have the correct output but never told us what the code output was. That's not helpful.
Also remember that we don't have the code or LCD in front of us. We know NOTHING about the LCD. We don't know what commands are available or what those hex commands you are sending with LCD_Cmd() are supposed to do.
Also, giving just one input and output is not enough. We need more of them to figure out what the code and LCD are actually doing. We need multiple test cases.
Most of the time in this thread all you do is go "This is what I have. It's not working. What's wrong with it?" Then we provide a suggestion and all you do is come back and say "It doesn't work." You don't even tell us what it did most of the time. It feels like you're just sitting there waiting for us to reply without thinking or trying anything on your own You need to spend that time making little changes to your code and investigating what it does to try and give us new information to boil down the behaviour of the problem.
---
For example, look at the image of the LCD screen you provided. Did you even think about it very much?
Hello Friend's
lo Friend's Hell
What happened to the missing "Hel" at the beginning of the second line? I don't know because I don't have enough information. You provided a single image of what you said was moving text. Some text could be going off the edge of the display and getting cut off before moving to a new line or something else. I have no idea. If it's moving text, show more than one image or else it's like trying to understand a video from a single frame. Also, don't use "Hello World" or "Hello Friends". It's not a good test string. Use strings of non-repeating, easily countable characters "1234567890abcdefghik". Try strings that are short enough that they can be repeated on the screen as well as strings that are long enough that will run off the edge of the screen or wraparound to a newline. That will make it easy to identify different things like how many characters are being displayed, when they are repeating or moving to a new line, and which character positions always go missing.
---
Start like this: Feed many inputs that will provide unique results that will tell you about different things in the system and see how the system reacts. In this case, feed short strings and a very long strings into the LCD and see what happens. The string needs to be non-repeating characters so you won't get confused if something appears twice. Like "123" and "123\n". Then feed long strings that will have to run off the edge of the screen or wrap around like "1234567890abcdefghijk", and "1234567890abcdefghijk\n".
Does the short string move or repeat? How does it move or repeat? How does the \n change things?
Does the long version repeat? Does it run off the edge of the screen or move onto a new line? Or does it do both where it runs off the edge of the screen for a bit and then move onto a new line so characters in the middle are missing?
Do things like this to hunt down exactly how the LCD and code are behaving. It's not enough to just show us one input and one output and expect us to be very helpful. You have to do some investigative work to try and boil down what the program and LCD are actually doing.
Also change the 'i' in your for loop to different numbers and see how it behaves. How does do different values of i affect what is printed out?