求一个51单片机程序:串口助手发送数据,然后在12864上显示。急呀
展开全部
#include <reg51.h>
#include <intrins.h>
#include <stdio.h>
#define uchar unsigned char
#define Fisrt_Addr 0 //定义字符/汉字显示起始位置
sbit LCD_RS=P2^2;
sbit LCD_RW=P2^3;
sbit LCD_E=P2^4;
sbit PCB=P2^5;
uchar i,j;
void delay(int ms)
{
while(ms--)
{
for(j=0;j<120;j++);
}
}
bit lcd_busy()
{ bit result;
LCD_RS=0;
LCD_RW=1;
LCD_E= 1;
result=(bit)(P0&0x80);
LCD_E=0;
return result;
}
void lcd_wcmd(uchar cmd)
{
while(lcd_busy());
LCD_RS=0;
LCD_RW=0;
P0=cmd;
LCD_E=1;
LCD_E=0;
}
void lcd_wdata(uchar dat)
{
while(lcd_busy());
LCD_RS=1;
LCD_RW=0;
P0=dat ;
LCD_E=1;
LCD_E=0;
}
void lcd_initial()
{
lcd_wcmd(0x30);
delay(1);
lcd_wcmd(0x0C); //开显示,关光标,不闪烁
delay(1);
lcd_wcmd(0x06);//指定在资料写入或读取时,光标的移动方向
delay(1);
lcd_wcmd(0x01);
delay(10); //这里要延时长一点,否侧会影响下面的操作
}
/*------------------清屏命令--------------------------*/
void Clr_Screen()
{
//考虑到前面出现0x34
lcd_wcmd(0x01);
delay(100);
}
void Zi_FU(uchar code *s)
{
while(*s!=0)
{ lcd_wdata(*s);
s++;
delay(10);
}
}
void feeling1()
{
lcd_wcmd(0x30);
delay(300);
lcd_wcmd(0x80+Fisrt_Addr);
Zi_FU("2013 03 26");
delay(300);
lcd_wcmd(0x90+Fisrt_Addr);
Zi_FU("电气08-17");
delay(300);
lcd_wcmd(0x88+Fisrt_Addr);
Zi_FU("ne-qi");
delay(300);
lcd_wcmd(0x98+Fisrt_Addr);
delay(500);
Zi_FU("2012.5.30");
}
void main()
{
PCB=1;
while(1)
{
lcd_initial();
delay(1000);
Clr_Screen();
feeling1();
delay(3000);
for(i=8;i>0;i--)
{
lcd_wcmd(0x18); //一二行与三四行调换了,液晶分为上下两个半屏,
delay(1000);
}
Clr_Screen();
feeling1();
lcd_wcmd(0x34);
lcd_wcmd(0x04);
delay(3000);
lcd_wcmd(0x04); //恢复正常
delay(3000);
lcd_wcmd(0x34);
lcd_wcmd(0x03); //允许输入滚动地址
for(i=0x40;i<0x7f;i++)
{
lcd_wcmd(i); //垂直滚动屏幕的内容
delay(600); //上翻屏延时
}
}
}
#include <intrins.h>
#include <stdio.h>
#define uchar unsigned char
#define Fisrt_Addr 0 //定义字符/汉字显示起始位置
sbit LCD_RS=P2^2;
sbit LCD_RW=P2^3;
sbit LCD_E=P2^4;
sbit PCB=P2^5;
uchar i,j;
void delay(int ms)
{
while(ms--)
{
for(j=0;j<120;j++);
}
}
bit lcd_busy()
{ bit result;
LCD_RS=0;
LCD_RW=1;
LCD_E= 1;
result=(bit)(P0&0x80);
LCD_E=0;
return result;
}
void lcd_wcmd(uchar cmd)
{
while(lcd_busy());
LCD_RS=0;
LCD_RW=0;
P0=cmd;
LCD_E=1;
LCD_E=0;
}
void lcd_wdata(uchar dat)
{
while(lcd_busy());
LCD_RS=1;
LCD_RW=0;
P0=dat ;
LCD_E=1;
LCD_E=0;
}
void lcd_initial()
{
lcd_wcmd(0x30);
delay(1);
lcd_wcmd(0x0C); //开显示,关光标,不闪烁
delay(1);
lcd_wcmd(0x06);//指定在资料写入或读取时,光标的移动方向
delay(1);
lcd_wcmd(0x01);
delay(10); //这里要延时长一点,否侧会影响下面的操作
}
/*------------------清屏命令--------------------------*/
void Clr_Screen()
{
//考虑到前面出现0x34
lcd_wcmd(0x01);
delay(100);
}
void Zi_FU(uchar code *s)
{
while(*s!=0)
{ lcd_wdata(*s);
s++;
delay(10);
}
}
void feeling1()
{
lcd_wcmd(0x30);
delay(300);
lcd_wcmd(0x80+Fisrt_Addr);
Zi_FU("2013 03 26");
delay(300);
lcd_wcmd(0x90+Fisrt_Addr);
Zi_FU("电气08-17");
delay(300);
lcd_wcmd(0x88+Fisrt_Addr);
Zi_FU("ne-qi");
delay(300);
lcd_wcmd(0x98+Fisrt_Addr);
delay(500);
Zi_FU("2012.5.30");
}
void main()
{
PCB=1;
while(1)
{
lcd_initial();
delay(1000);
Clr_Screen();
feeling1();
delay(3000);
for(i=8;i>0;i--)
{
lcd_wcmd(0x18); //一二行与三四行调换了,液晶分为上下两个半屏,
delay(1000);
}
Clr_Screen();
feeling1();
lcd_wcmd(0x34);
lcd_wcmd(0x04);
delay(3000);
lcd_wcmd(0x04); //恢复正常
delay(3000);
lcd_wcmd(0x34);
lcd_wcmd(0x03); //允许输入滚动地址
for(i=0x40;i<0x7f;i++)
{
lcd_wcmd(i); //垂直滚动屏幕的内容
delay(600); //上翻屏延时
}
}
}
本回答被提问者和网友采纳
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
展开全部
找论文上面有
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询