以下是程序
#include<reg52.h>
#include<intrins.h>
sbit rs=P1^3;
sbit rw=P1^4;
sbit e=P1^5;
sbit psb=P1^6;
void write_12864com(char com);
void write_12864dat(char dat);
void ini
tinal(void);
void display1(void);
void delay_50us(int t)
{
char j;
for(;t>0;t--)
for(j=19;j>0;j--);
}
void delay_50ms(int t)
{
int j;
for(;t>0;t--)
for(j=6245;j>0;j--);
}
void main()
{
initinal();
while(1)
{
display1();
//display3();
while(1);
}
}
void write_12864com(char com)
{
rw=0;
rs=0;
delay_50us(1);
P0=com;
e=1;
delay_50us(10);
e=0;
delay_50us(2);
}
void write_12864dat(char dat)
{
rw=0;
rs=1;
delay_50us(1);
P0=dat;
e=1;
delay_50us(10);
e=0;
delay_50us(2);
}
void initinal(void)
{
delay_50ms(2);
write_12864com(0x30);
delay_50us(4);
write_12864com(0x30);
delay_50us(4);
write_12864com(0x0f);
delay_50us(4);
write_12864com(0x01);
delay_50us(240);
write_12864com(0x06);
delay_50us(10);
}
void display1(void)
{
char i;
char a;
a=0x10;;
write_12864com(0x80);
delay_50us(1);
for(i=0;i<16;i++)
{
write_12864dat(a);
delay_50us(1);
a++;
}
}
以上是程序和图片,我觉得我定义的引脚io口应该没问题啊 可就是显示不了数字
就像下面这样
你刷屏的时候,是不是全刷了?
一周热门 更多>