51单片机简单的1062液晶显示程序求助
答案:3 悬赏:30 手机版
解决时间 2021-03-14 08:52
- 提问者网友:蓝琪梦莎
- 2021-03-14 02:21
51单片机简单的1062液晶显示程序求助
最佳答案
- 五星知识达人网友:白昼之月
- 2021-03-14 03:11
光看代码你是不能了解它的使用历程的,最好看看使用手册,下面的代码是用1602液晶
#include<reg52.h>
#define uchar unsigned char
#define uint unsigned int
uchar code table[]="I LIKE MCU!";
uchar code table1[]="www.TXMCU.COM";
sbit lcden=P3^4;
sbit lcdrs=P3^5;
sbit dula=P2^6;
sbit wela=P2^7;
uchar num;
void delay(uint z)
{
uint x,y;
for(x=z;x>0;x--)
for(y=110;y>0;y--);
}
void write_com(uchar com)
{
lcdrs=0;
P0=com;
delay(5);
lcden=1;
delay(5);
lcden=0;
}
void write_data(uchar date)
{
lcdrs=1;
P0=date;
delay(5);
lcden=1;
delay(5);
lcden=0;
}
void init()
{
dula=0;
wela=0;
lcden=0;
write_com(0x38);
write_com(0x0e);
write_com(0x06);
write_com(0x01);
write_com(0x80+0x10);
}
void main()
{
init();
for(num=0;num<11;num++)
{
write_data(table[num]);
delay(20);
}
// write_com(1);
write_com(0x80+0x53);
for(num=0;num<13;num++)
{
write_data(table1[num]);
delay(20);
}
for(num=0;num<16;num++)
{
write_com(0x18);
delay(20);
}
while(1);
}
#include<reg52.h>
#define uchar unsigned char
#define uint unsigned int
uchar code table[]="I LIKE MCU!";
uchar code table1[]="www.TXMCU.COM";
sbit lcden=P3^4;
sbit lcdrs=P3^5;
sbit dula=P2^6;
sbit wela=P2^7;
uchar num;
void delay(uint z)
{
uint x,y;
for(x=z;x>0;x--)
for(y=110;y>0;y--);
}
void write_com(uchar com)
{
lcdrs=0;
P0=com;
delay(5);
lcden=1;
delay(5);
lcden=0;
}
void write_data(uchar date)
{
lcdrs=1;
P0=date;
delay(5);
lcden=1;
delay(5);
lcden=0;
}
void init()
{
dula=0;
wela=0;
lcden=0;
write_com(0x38);
write_com(0x0e);
write_com(0x06);
write_com(0x01);
write_com(0x80+0x10);
}
void main()
{
init();
for(num=0;num<11;num++)
{
write_data(table[num]);
delay(20);
}
// write_com(1);
write_com(0x80+0x53);
for(num=0;num<13;num++)
{
write_data(table1[num]);
delay(20);
}
for(num=0;num<16;num++)
{
write_com(0x18);
delay(20);
}
while(1);
}
全部回答
- 1楼网友:执傲
- 2021-03-14 04:47
#include<reg52.h>
#define uchar unsigned char
#define uint unsigned int
sbit dula=P2^6;
sbit wela=P2^7;
sbit lcden=P3^4;
sbit lcdrs=P3^5;
sbit key1=P3^0;
sbit key2=P3^1;
sbit key3=P3^2;
//sbit key4=P3^3;
sbit key=P3^7;
void display();
void delayms(uint z);
void keysscan();
void init();
void write_com(uchar com);
void write_data(uchar date);
uchar num,num1,num2;num3,num4;
uchar sshi,sge,fshi,fge,mshi,mge;
uint temp=0;
void init() //初始化
{
dula=0;
wela=0;
TMOD=0x01;
TH0=(65536-45872)/256;
TH1=(65536-45872)%256;
EA=1;
ET0=1;
TR0=1;
lcden=0;
write_com(0x38);
write_com(0x0c);
write_com(0x06);
write_com(0x01);
}
void write_com(uchar com) //写指令
{
lcdrs=0;
P0=com;
delayms(5);
lcden=1;
delayms(5);
lcden=0;
}
void write_data(uchar date)//写数据
{
lcdrs=1;
P0=date;
delayms(5);
lcden=1;
delayms(5);
lcden=0;
}
void delayms(uint z)//延时
{
uint i,j;
for(i=z;i>0;i--)
for(j=110;j>0;j--);
}
void display()//液晶屏显示
{
write_com(0x80);
write_data(sshi+48);
delayms(1);
write_com(0x80+0x01);
write_data(sge+48);
delayms(1);
write_com(0x80+0x02);
write_data(':');
delayms(1);
write_com(0x80+0x03);
write_data(fshi+48);
delayms(1);
write_com(0x80+0x04);
write_data(fge+48);
delayms(1);
write_com(0x80+0x05);
write_data(':');
delayms(1);
write_com(0x80+0x06);
write_data(mshi+48);
delayms(1);
write_com(0x80+0x07);
write_data(mge+48);
delayms(1);
}
void keysscan()
{
key=0;
if(key1==0)
{
delayms(5);
if(key1==0);
{
while(!key1);
temp++;
TR0=0;
write_com(0x0f);
}
}
switch(temp)
{
case 1:
if(key2==0)
{
delayms(5);
if(key2==0);
{
while(!key2)
num1++;
if(num1==60)num1=0;
}
}
if(key3==0)
{
delayms(5);
if(key3==0)
{
while(!key3)
num1--;
if(num1==-1)num1=0;
}
}
break;
case 2:
{
if(key2==0)
{
delayms(5);
if(key2==0)
{
while(!key2);
num2++;
if(num2==60)num2=0;
}
}
if(key3==0)
{
delayms(5);
if(key3==0)
{
while(!key3);
num2--;
if(num2==-1)num2=0;
}
}
}
break;
case 3:
{ if(key2==0)
{
delayms(5);
if(key2==0)
{
while(!key2);
num3++;
if(num3==60)num3=0;
}
}
if(key3==0)
{
delayms(5);
if(key3==0)
{
while(!key3);
num3--;
if(num3==-1)num3=0;
}
}
}
break;
case 4:
{
temp=0;
TR0=1;
write_com(0x08);
}
}
}
void T0_time()interrupt 1 //时钟0中断
{
num++;
TH0=(65536-45872)/256;
TH1=(65536-45872)%256;
if(num==20)
{
num=0;
num1++;
if(num1==60)
{
num1=0;
num2++;
}
mshi=num1/10;
mge=num1%10;
if(num2==60)
{
num2=0;
num3++;
}
fshi=num2/10;
fge=num2%10;
if(num3==24)
{
num3=0;
// num4++;
}
sshi=num3/10;
sge=num3%10;
//if(num4)
display();
}
}
void main()
{
init();
while(1)
{
keysscan();
}
}
- 2楼网友:过活
- 2021-03-14 04:15
光看代码你是不能了解它的使用历程的,最好看看使用手册,下面的代码是用1602液晶#include#define uchar unsigned char#define uint unsigned intuchar code table[]="i like mcu!";uchar code table1[]="(uchar com){lcdrs=0;p0=com;delay(5);lcden=1;delay(5);lcden=0;}void write_data(uchar date){lcdrs=1;p0=date;delay(5);lcden=1;delay(5);lcden=0;}void init(){dula=0;wela=0;lcden=0;write_com(0x38);write_com(0x0e);write_com(0x06);write_com(0x01);write_com(0x80+0x10);}void main(){init();for(num=0;num<11;num++){write_data(table[num]);delay(20);}//write_com(1);write_com(0x80+0x53);for(num=0;num<13;num++){write_data(table1[num]);delay(20);}for(num=0;num<16;num++){write_com(0x18);delay(20);}while(1);}51单片机简单的1062液晶显示程序求助
我要举报
如以上问答信息为低俗、色情、不良、暴力、侵权、涉及违法等信息,可以点下面链接进行举报!
大家都在看
推荐资讯