#include <reg52.h>
#include <intrins.h>
#define uchar unsigned char
#define uint unsigned int
unsigned char code word1[]={"FUCK YOU"};//单字符用单引号双字符用双引号
unsigned char code word2[]={"Asshole"};
sbit RS = P1^0 ;
sbit RW = P1^1 ;
sbit EN = P2^5 ;
sbit STA7 = P0^7;
void wait()
{
P0 = 0xFF;
do
{
RS = 0;
RW = 1;
EN = 0;
EN = 1;
}while (STA7 == 1);
EN = 0;
}
void w_dat(uint dat)
{
wait();
EN = 0;
P0 = dat;
RS = 1;
RW = 0;
EN = 1;
EN = 0;
}
void w_cmd(uint cmd)
{
wait();
EN = 0;
P0 = cmd;
RS = 0;
RW = 0;
EN = 1;
EN = 0;
}
void w_string(uint addr_start,uint *p)
{
w_cmd(addr_start);
while (*p != '\0')
{
w_dat(*p++);
}
}
void Init_LCD1602()
{
w_cmd(0x38); // 16*2显示,5*7点阵,8位数据接口
w_cmd(0x0C); // 显示器开、光标开、光标允许闪烁
w_cmd(0x06); // 文字不动,光标自动右移
w_cmd(0x01); // 清屏
}
main()
{
Init_LCD1602();
w_string(0x80,word1);
w_string(0xC0,word2);
while (1);
}
200字以内,仅用于支线交流,主线讨论请采用回复功能。