基于51单片机的lcd1602液晶显示的计算器Word格式文档下载.docx
- 文档编号:13239627
- 上传时间:2022-10-08
- 格式:DOCX
- 页数:16
- 大小:29.32KB
基于51单片机的lcd1602液晶显示的计算器Word格式文档下载.docx
《基于51单片机的lcd1602液晶显示的计算器Word格式文档下载.docx》由会员分享,可在线阅读,更多相关《基于51单片机的lcd1602液晶显示的计算器Word格式文档下载.docx(16页珍藏版)》请在冰豆网上搜索。
sbitlcdrw=P2^1;
sbitlcdrs=P2^0;
ucharnum,temp,jia=0,jian=0,cheng=0,chu=0,qing=0;
uintkey,key1,shu;
ucharfuhao,flag1,flag=0;
uchartable[]={
0x3f,0x06,0x5b,0x4f,0x66,0x6d,0x7d,0x07,
0x7f,0x6f,0x0};
voiddelay(uintz){
uintx,y;
for(x=z;
x>
0;
x--)
for(y=110;
y>
y--);
}
bitlcd_bz()
{
bitresult;
lcdrs=0;
lcdrw=1;
lcden=1;
_nop_();
result=(bit)(P0&
0x80);
lcden=0;
returnresult;
voidwrite_com(ucharcom)
while(lcd_bz());
lcdrw=0;
P0=com;
delay(5);
voidwrite_date(uchardate)
lcdrs=1;
P0=date;
}
voidlcd_init(){
write_com(0x38);
write_com(0x0c);
write_com(0x06);
write_com(0x01);
voidkeyscan(){
P3=0xfe;
temp=P3;
temp=temp&
0xf0;
while(temp!
=0xf0)
switch(temp)
case0xee:
key=1;
num=0;
break;
case0xde:
key=2;
case0xbe:
key=3;
case0x7e:
num=1;
//加号
P3=0xfd;
case0xed:
key=4;
case0xdd:
key=5;
case0xbd:
key=6;
case0x7d:
num=2;
//减号
P3=0xfb;
case0xeb:
key=7;
case0xdb:
key=8;
case0xbb:
key=9;
case0x7b:
num=3;
//乘号
P3=0xf7;
case0xe7:
key=0;
case0xd7:
num=6;
//清除
case0xb7:
num=5;
//等于号
case0x77:
num=4;
//除号
voiddisplay0(uintshu){
uintge;
ge=shu;
write_date(0x30+ge);
voiddisplay1(uintshu){
uintshi,ge;
shi=shu/10;
ge=shu%10;
write_date(0x30+shi);
voiddisplay2(uintshu){
uintbai,shi,ge;
bai=shu/100;
shi=shu%100/10;
write_date(0x30+bai);
voiddisplay3(uintshu){
uintqian,bai,shi,ge;
qian=shu/1000;
bai=shu%1000/100;
write_date(0x30+qian);
voiddisplay4(uintshu){
uintwan,qian,bai,shi,ge;
wan=shu/10000;
qian=shu%10000/1000;
write_date(0x30+wan);
voiddisplay_key1(uintresult)
if(flag1==1)
flag1=0;
shu=result;
write_com(0x80);
if(result<
10)
display0(result);
if(result>
=10&
&
result<
100)
display1(result);
=100&
1000)
display2(result);
=1000&
10000)
display3(result);
=10000)
display4(result);
voiddis_key(result)
voiddisplay_key(uintresult){
if(shu<
write_com(0x80+2);
dis_key(result);
if(shu>
shu<
write_com(0x80+3);
write_com(0x80+4);
write_com(0x80+5);
write_com(0x80+6);
voiddisplay_fuhao()
switch(fuhao)
case1:
write_date(0x2b);
case2:
write_date(0x2d);
case3:
write_date(0x2a);
case4:
write_date(0x2f);
fuhao=0;
voidfuhao_pan()
write_com(0x80+1);
display_fuhao();
w
- 配套讲稿:
如PPT文件的首页显示word图标,表示该PPT已包含配套word讲稿。双击word图标可打开word文档。
- 特殊限制:
部分文档作品中含有的国旗、国徽等图片,仅作为作品整体效果示例展示,禁止商用。设计者仅对作品中独创性部分享有著作权。
- 关 键 词:
- 基于 51 单片机 lcd1602 液晶显示 计算器
![提示](https://static.bdocx.com/images/bang_tan.gif)