0% found this document useful (0 votes)
29 views

Void Main (For ( ) (Init Lcddata (10) ) )

This code is controlling an LCD display using a microcontroller. It initializes the LCD to 8-bit 2 row mode and turns on the display and cursor. It defines functions to send commands and data to the LCD. The main function continuously sends the number 10 to the LCD data function.
Copyright
© Attribution Non-Commercial (BY-NC)
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
29 views

Void Main (For ( ) (Init Lcddata (10) ) )

This code is controlling an LCD display using a microcontroller. It initializes the LCD to 8-bit 2 row mode and turns on the display and cursor. It defines functions to send commands and data to the LCD. The main function continuously sends the number 10 to the LCD data function.
Copyright
© Attribution Non-Commercial (BY-NC)
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 2

#include<reg51.

h>
#define cmdport P2
#define dataport P0

sbit rs = cmdport^4; //register select pin


sbit rw = cmdport^6; // read write pin
sbit e = cmdport^7; //enable pin
sbit busy = dataport^7; // busy detection

void init(void);
void lcdcmd(unsigned char);
void getReady(void);
void lcddata(int);

void main()

for(;;)

init();

lcddata(10);

void init()

lcdcmd(0x38); // for using 8-bit 2 row mode of LCD


lcdcmd(0x0E); // turn display ON for cursor blinking
lcdcmd(0x01); //clear screen
lcdcmd(0x06); //display ON
lcdcmd(0x86); // bring cursor to position 6 of line 1
}

void lcdcmd(unsigned char item) //Function to send command to LCD


{
char dd;
getReady();
dataport = item;
rs= 0;
rw=0;
e=1;
dd++;
e=0;
}

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;
}

void lcddata(unsigned int item) //Function to send data to LCD


{
char dd;
getReady();
rs= 1;
rw=0;
e=1;
dataport = item;
dd++;
e=0;
}

You might also like