我想在特定行列中顯示字母16x2液晶屏顯示屏8051
MCU。例如:如何在LCD顯示屏中選擇行列
Display "R" at 2nd column in first row
Display "W" at 3rd column in second row
我使用這些例程用於LCD:
#include<reg51.h>
/* Data pins connected to port P1 of 8051 */
#define Data_Port_Pins (P1)
sbit Register_Select_Pin = P2^0; /* Register Pin of LCD connected to Pin 0 of Port P2 */
sbit Read_Write_Pin = P2^1; /* Read/Write Pin of LCD connected to Pin 1 of Port P2 */
sbit Enable_Pin = P2^2; /* EN pin connected to pin 2 of port P2 */
/* Function for creating delay in milliseconds */
void Delay(unsigned int wait)
{
volatile 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 command)
{
Data_Port_Pins = command;
Register_Select_Pin =0;
Read_Write_Pin=0;
Enable_Pin =1;
Delay (2);
Enable_Pin =0;
}
/* Function to send display data to LCD */
void LCD_Data (unsigned char Data)
{
Data_Port_Pins = Data;
Register_Select_Pin=1;
Read_Write_Pin=0;
Enable_Pin =1;
Delay(2);
Enable_Pin =0;
}
/* Function to prepare the LCD and get it ready */
void LCD_Initialization()
{
LCD_Command (0x38);
LCD_Command (0x0e);
LCD_Command (0x01);
LCD_Command (0x81);
}
這是我的嘗試:
這有什麼意義嗎?
void LCD_Position(char row, char column)
{
unsigned char cmd = 0x80 ; /* Start address */
if(row != 0) /*If second row selected ...*/
{
cmd += 0x40 ; /*add start address of second row */
}
cmd += row & 0x0f ;
LCD_Command (cmd);
}
你嘗試過什麼?目前看起來你只是貼上了你所得到的問題。另外,如果不知道你連接的LCD是什麼,這裏沒有人可以幫助你。 – Ross
我可以在LCD上編寫消息顯示程序,我已經寫好了。並用模擬器測試它的工作正常。在那之後,我嘗試編寫程序來在特定的行和列上顯示字母..但我不知道如何在特定的行和列上顯示字母我使用16 * 2 LCD – Parth786
在'Delay()'中,聲明'i'和'j'' volatile'('volatile unsigned i,j;') – Clifford