#include<reg52.h>
#include<intrins.h>
#define uchar unsigned char
#define uint unsigned int
sbit lcden = P2^7;
sbit lcdrs = P2^6;
sbit lcdrw = P2^5;
void display();
void delay(uchar z);
void writedata(uchar dat);
void writecom(uchar com);
void init();
void main()
{
init();
while(1)
{
display();
}
}
void display()
{
uchar temp;
P1 = 0x7f;
temp = P1;
temp = temp & 0x0f;
if(temp != 0x0f)
{
delay(30);
temp = P1;
temp = temp & 0x0f;
if(temp != 0x0f)
{
switch (temp)
{
case 0x07:writedata('/');
break;
case 0x0b:writedata('*');
break;
case 0x0d:writedata('-');
break;
case 0x0e:writedata('+');
break;
}
}
while(temp != 0x0f)
{
temp = P1;
temp = temp & 0x0f;
}
}
P1 = 0xbf;
temp = P1;
temp = temp & 0x0f;
if(temp != 0x0f)
{
delay(30);
temp = P1;
temp = temp & 0x0f;
if(temp != 0x0f)
{
switch (temp)
{
case 0x07:writedata('=');
break;
case 0x0b:writedata('3');
break;
case 0x0d:writedata('6');
break;
case 0x0e:writedata('9');
break;
}
}
while(temp != 0x0f)
{
temp = P1;
temp = temp & 0x0f;
}
}
P1 = 0xdf;
temp = P1;
temp = temp & 0x0f;
if(temp != 0x0f)
{
delay(30);
temp = P1;
temp = temp & 0x0f;
if(temp != 0x0f)
{
switch (temp)
{
case 0x07:writedata('0');
break;
case 0x0b:writedata('2');
break;
case 0x0d:writedata('5');
break;
case 0x0e:writedata('8');
break;
}
}
while(temp != 0x0f)
{
temp = P1;
temp = temp & 0x0f;
}
}
P1 = 0xef;
temp = P1;
temp = temp & 0x0f;
if(temp != 0x0f)
{
delay(30);
temp = P1;
temp = temp & 0x0f;
if(temp != 0x0f)
{
switch (temp)
{
case 0x07:writedata('.');
break;
case 0x0b:writedata('1');
break;
case 0x0d:writedata('4');
break;
case 0x0e:writedata('7');
break;
}
}
while(temp != 0x0f)
{
temp = P1;
temp = temp & 0x0f;
}
}
}
void init()
{
writecom(0x38);
writecom(0x0f);
writecom(0x06);
writecom(0x01);
writecom(0x80);
}
void writecom(uchar com)
{
lcden = 0;
lcdrs = 0;
lcdrw = 0;
P0 = com;
delay(5);
lcden = 1;
delay(5);
lcden = 0;
}
void writedata(uchar dat)
{
lcden = 0;
lcdrs = 1;
lcdrw = 0;
P0 = dat;
delay(5);
lcden = 1;
delay(5);
lcden = 0;
}
void delay(uchar z)
{
uchar a, b;
for(a = z; a > 0; a--)
for(b = 110; b > 0; b--);
}
QQ594011024 完成了可以加我QQ,本人保证支付支付宝30元感谢费。。
我需要,谢谢
一周热门 更多>