用stc12c5a60s2芯片1602上显示不出来
时间:10-02
整理:3721RD
点击:
#include <stc12c5a60s2.h>
#define uint unsigned int
#define uchar unsigned char
uchar code table[]="I LOVE YOU";
uchar code table1[]="what is fuck";
sbit lcden=P4^5;
sbit lcdrs=P4^6;
sbit rw=P4^1;
uchar num;
void delay(uint z)
{
uint x,y;
for(x=z;x>0;x--)
for(y=800;y>0;y--);
}
void write_com(uchar com)
{
lcdrs=0;
P0=com;
delay(5);
rw=0;
lcden=0;
}
void write_data(uchar date)
{
lcdrs=1;
P0=date;
rw=0;
delay(5);
lcden=1;
delay(5);
lcden=0;
}
void init()
{
lcden=0;
write_com(0x38);
write_com(0x0c);
write_com(0x06);
write_com(0x01);
}
void main ()
{
P4SW = 0x32;
init();
write_com(0x80);
for(num=0;num<11;num++)
{
write_data(table[num]);
delay(5);
}
write_com(0x80+0x40);
for(num=0;num<13;num++)
{
write_data(table1[num]);
delay(5);
}
while(1);
}
编的语法没屏幕只亮不显示错问一下 哪里错了
#define uint unsigned int
#define uchar unsigned char
uchar code table[]="I LOVE YOU";
uchar code table1[]="what is fuck";
sbit lcden=P4^5;
sbit lcdrs=P4^6;
sbit rw=P4^1;
uchar num;
void delay(uint z)
{
uint x,y;
for(x=z;x>0;x--)
for(y=800;y>0;y--);
}
void write_com(uchar com)
{
lcdrs=0;
P0=com;
delay(5);
rw=0;
lcden=0;
}
void write_data(uchar date)
{
lcdrs=1;
P0=date;
rw=0;
delay(5);
lcden=1;
delay(5);
lcden=0;
}
void init()
{
lcden=0;
write_com(0x38);
write_com(0x0c);
write_com(0x06);
write_com(0x01);
}
void main ()
{
P4SW = 0x32;
init();
write_com(0x80);
for(num=0;num<11;num++)
{
write_data(table[num]);
delay(5);
}
write_com(0x80+0x40);
for(num=0;num<13;num++)
{
write_data(table1[num]);
delay(5);
}
while(1);
}
编的语法没屏幕只亮不显示错问一下 哪里错了
你延时的时间不对,需要把它的时间再延时一下!
P4SW = 0x32;这句错了
你还没有把P4.6设置成IO口啊
我还是新手的 看不懂