求单片机+1602/12864显示的RC522程序! 10
3个回答
展开全部
看看, RS在P3^5,RW在P3^6, E在P3^4
这是1602的,需要12864的话再给你,忘采纳
#include<reg52.h>
#define uchar unsigned char
#define uint unsigned int
uchar table1[]={"wo shi yang lang"};
uchar table2[]={"dan pian ji"};
// uchar table3[]={};
// uchar table4[]={};
sbit wei=P2^7;
sbit duan=P2^6;
sbit E=P3^4;
sbit RS=P3^5;
sbit RW=P3^6;
unsigned char num;
void delay(unsigned char z)
{
unsigned char x,y;
for(x=0;x<z;x++)
for(y=0;y<110;y++);
}
void zl(unsigned char a)
{
RS=0;
RW=0;
P0=a;
E=0;
delay(5);
E=1;
delay(5);
E=0;
}
void sj(unsigned char b)
{
RS=1;
RW=0;
P0=b;
E=0;
delay(5);
E=1;
delay(5);
E=0;
}
void iniv()
{
wei=0;
duan=0;
E=0;
zl(0x01);
zl(0x80);
zl(0x38);
zl(0x0f);
}
void main()
{
iniv();
zl(0x80+0x10);
for(num=0;num<16;num++)
{
sj(table1[num]);
delay(1200);
}
zl(0x80+0x40+3+0x10);
for(num=0;num<11;num++)
{
sj(table2[num]);
delay(1200);
}
for(num=0;num<16;num++)
{
zl(0x18);
delay(200);
}
while(1);
}
这是1602的,需要12864的话再给你,忘采纳
#include<reg52.h>
#define uchar unsigned char
#define uint unsigned int
uchar table1[]={"wo shi yang lang"};
uchar table2[]={"dan pian ji"};
// uchar table3[]={};
// uchar table4[]={};
sbit wei=P2^7;
sbit duan=P2^6;
sbit E=P3^4;
sbit RS=P3^5;
sbit RW=P3^6;
unsigned char num;
void delay(unsigned char z)
{
unsigned char x,y;
for(x=0;x<z;x++)
for(y=0;y<110;y++);
}
void zl(unsigned char a)
{
RS=0;
RW=0;
P0=a;
E=0;
delay(5);
E=1;
delay(5);
E=0;
}
void sj(unsigned char b)
{
RS=1;
RW=0;
P0=b;
E=0;
delay(5);
E=1;
delay(5);
E=0;
}
void iniv()
{
wei=0;
duan=0;
E=0;
zl(0x01);
zl(0x80);
zl(0x38);
zl(0x0f);
}
void main()
{
iniv();
zl(0x80+0x10);
for(num=0;num<16;num++)
{
sj(table1[num]);
delay(1200);
}
zl(0x80+0x40+3+0x10);
for(num=0;num<11;num++)
{
sj(table2[num]);
delay(1200);
}
for(num=0;num<16;num++)
{
zl(0x18);
delay(200);
}
while(1);
}
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询