• 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.

LCD dispay coding

Tony STArk

New Member
C:
#include<pic.h>
#define rs RC0
#define rw RC1
#define en RC2
void delay();
void lcd1();
void cmd(unsigned char a);
void data(unsigned char b);


void lcd1()    //Function to prepare the LCD  and get it ready
{
    cmd(0x38);  // for using 2 lines and 5X7 matrix of LCD
    cmd(0x0F);  // turn display ON, cursor blinking
    cmd(0x01);  //clear scree
    cmd(0x81);  // bring cursor to position 1 of line 1
    }
    void cmd(unsigned char a)  //Function to send command instruction to LCD
{
    PORTB = a;
    rs= 0;
    rw=0;
    en=1;
    delay();
    en=0;
}

void data(unsigned char b)  //Function to send display data to LCD
{
    PORTB = b;
    rs= 1;
    rw=0;
    en=1;
    delay();
    en=0;
}
void delay()
{
int i;
    for( i=0;i<=1000;i++);
    }
void main()
{
TRISB=0x00;
TRISC=0x00;
    char c[]="JARVIS";
    lcd1();
    int d=0;
    while(c[d]=='\0')
    {
        data(c[d]);
        d++;
        }
}
on my simulation result lcd on ,cursor on but the data was not properly display.
 
Last edited by a moderator:

gophert

Well-Known Member
Most Helpful Member
In addition to the delays (16x2 LCDs are very slow devices), you also need a bias voltage on the bias pin. Adjust the bias voltage until you can see faint gray rectangles over each character.
 

Latest threads

EE World Online Articles

Loading

 
Top