0% found this document useful (0 votes)
17 views2 pages

Coduri

The document defines functions for initializing and sending commands and data to an LCD display module. It includes functions for delay, sending command and data, writing a string to the display, and initializing the LCD module.

Uploaded by

Szekely Marco
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
17 views2 pages

Coduri

The document defines functions for initializing and sending commands and data to an LCD display module. It includes functions for delay, sending command and data, writing a string to the display, and initializing the LCD module.

Uploaded by

Szekely Marco
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
You are on page 1/ 2

sfr LCD_Port=0xA0;

sbit rs=P2^0;
sbit en=P2^1;

void delay(unsigned int); // Prototipul func?iei delay


void LCD_Command (char);
void LCD_data (char);
void LCD_String (char *str);
void LCD_Init (void);

void delay(unsigned int count) // Defini?ia func?iei delay


{
int i,j;
for (i=0;i<count;i++) {
for (j=0;j<922;j++);
}
}

// Defini?ia func?iei LCD_Command


void LCD_Command(char cmd)
{
LCD_Port =(LCD_Port & 0x0F) | (cmd & 0xF0); /* Send upper nibble */
rs=0; /* Command reg. */
en=1;
delay (1);
en=0;
delay(1);

LCD_Port = (LCD_Port & 0x0F) | (cmd << 4); /* Send lower nibble */
en=1; /* Enable pulse */
delay(1);
en=0;
delay(1);
}

// Defini?ia func?iei LCD_data


void LCD_data (char char_data)
{
LCD_Port =(LCD_Port & 0x0F) | (char_data & 0xF0);
rs=1; /* Data reg. */
en=1;
delay (1);
en=0;
delay(1);

LCD_Port = (LCD_Port & 0x0F) | (char_data << 4);


en=1; /* Enable pulse */
delay(1);
en=0;
delay(1);
}

// Defini?ia func?iei LCD_String


void LCD_String (char *str)
{
int i;
for (i=0; str[i]!=0;i++)
{
LCD_data(str[i]);
}
}

// Defini?ia func?iei LCD_Init


void LCD_Init(void)
{
delay(20);
LCD_Command (0x02);
LCD_Command (0x28);
LCD_Command (0x0C);
LCD_Command (0x06);
LCD_Command (0x01);
LCD_Command (0x80);
}

You might also like