<dfn id="yhprb"><s id="yhprb"></s></dfn><dfn id="yhprb"><delect id="yhprb"></delect></dfn><dfn id="yhprb"></dfn><dfn id="yhprb"><delect id="yhprb"></delect></dfn><dfn id="yhprb"></dfn><dfn id="yhprb"><s id="yhprb"><strike id="yhprb"></strike></s></dfn><small id="yhprb"></small><dfn id="yhprb"></dfn><small id="yhprb"><delect id="yhprb"></delect></small><small id="yhprb"></small><small id="yhprb"></small> <delect id="yhprb"><strike id="yhprb"></strike></delect><dfn id="yhprb"></dfn><dfn id="yhprb"></dfn><s id="yhprb"><noframes id="yhprb"><small id="yhprb"><dfn id="yhprb"></dfn></small><dfn id="yhprb"><delect id="yhprb"></delect></dfn><small id="yhprb"></small><dfn id="yhprb"><delect id="yhprb"></delect></dfn><dfn id="yhprb"><s id="yhprb"></s></dfn> <small id="yhprb"></small><delect id="yhprb"><strike id="yhprb"></strike></delect><dfn id="yhprb"><s id="yhprb"></s></dfn><dfn id="yhprb"></dfn><dfn id="yhprb"><s id="yhprb"></s></dfn><dfn id="yhprb"><s id="yhprb"><strike id="yhprb"></strike></s></dfn><dfn id="yhprb"><s id="yhprb"></s></dfn>

新聞中心

EEPW首頁(yè) > 嵌入式系統 > 設計應用 > 單片機做的8位計算器

單片機做的8位計算器

作者: 時(shí)間:2016-12-01 來(lái)源:網(wǎng)絡(luò ) 收藏

CODE:

本文引用地址:http://dyxdggzs.com/article/201612/324178.htm

#include
#define uint unsigned int
#define uchar unsigned char
sbit dula=P2^6;
sbit wela=P2^7;
uchar LA[8];
uchar code wetable[]={
0x7f,0xbf,0xdf,0xef,
0xf7,0xfb,0xfd,0xfe};
uchar code dutable[]={
0x3f,0x06,0x5b,0x4f,
0x66,0x6d,0x7d,0x07,
0x7f,0x6f};//段選0~9
longint num1,num2,num;
uchar temp;//按鍵需要的中間變量
uchar flag;//標記是否為數字鍵
uchar ch;//保存當前按下的符號標記按鍵的次數,按下“+-*/”
uchar date,count;//date保存按鍵得到的數字,count標記是第幾個(gè)數字
uchar p;//p為指針,為了消除數字之前多余的0
uchar mark;
void delay(uint z)
{
uint x,y;
for(x=z;x>0;x--)
{
for(y=0;y<=112;y++)
{
}
}
}
void init()
{
count=0;
flag=0;
mark=0;
num1=0;
num2=0;
num=0;
}
uchar keyscan()//判斷按下那個(gè)鍵
{
P1=0xfe;
temp=P1;
temp=temp&0xf0;
if(temp!=0xf0)
{
delay(5);//消除抖動(dòng)
temp=P1;
temp=temp&0xf0;
while(temp!=0xf0)//證明有鍵按下,while語(yǔ)句是為了讓鍵盤(pán)松開(kāi)
{
temp=P1;
switch(temp)
{
case 0xee:flag=1;date=7;
break;
case 0xde:flag=1;date=8;
break;
case 0xbe:flag=1;date=9;
break;
case 0x7e:flag=2;ch=/;
break;
}
if(temp!=0xf0)
{
delay(5);
temp=P1;
temp=temp&0xf0;
while(temp!=0xf0)//等待按鍵松開(kāi)
{
temp=P1;
temp=temp&0xf0;
}
}
}
}
P1=0xfd;
temp=P1;
temp=temp&0xf0;
if(temp!=0xf0)
{
delay(5);//消除抖動(dòng)
temp=P1;
temp=temp&0xf0;
while(temp!=0xf0)//證明有鍵按下,while語(yǔ)句是為了讓鍵盤(pán)松開(kāi)
{
temp=P1;
switch(temp)
{
case 0xed:flag=1;date=4;
break;
case 0xdd:flag=1;date=5;
break;
case 0xbd:flag=1;date=6;
break;
case 0x7d:flag=2;ch=*;
break;
}
if(temp!=0xf0)
{
delay(5);
temp=P1;
temp=temp&0xf0;
while(temp!=0xf0)//等待按鍵松開(kāi)
{
temp=P1;
temp=temp&0xf0;
}
}
}
}
P1=0xfb;
temp=P1;
temp=temp&0xf0;
if(temp!=0xf0)
{
delay(5);//消除抖動(dòng)
temp=P1;
temp=temp&0xf0;
while(temp!=0xf0)//證明有鍵按下,while語(yǔ)句是為了讓鍵盤(pán)松開(kāi)
{
temp=P1;
switch(temp)
{
case 0xeb:flag=1;date=1;
break;
case 0xdb:flag=1;date=2;
break;
case 0xbb:flag=1;date=3;
break;
case 0x7b:flag=2;ch=-;
break;
}
if(temp!=0xf0)
{
delay(5);
temp=P1;
temp=temp&0xf0;
while(temp!=0xf0)//等待按鍵松開(kāi)
{
temp=P1;
temp=temp&0xf0;
}
}
}
}

P1=0xf7;
temp=P1;
temp=temp&0xf0;
if(temp!=0xf0)
{
delay(5);//消除抖動(dòng)
temp=P1;
temp=temp&0xf0;
while(temp!=0xf0)//證明有鍵按下,while語(yǔ)句是為了讓鍵盤(pán)松開(kāi)
{
temp=P1;
switch(temp)
{
case 0xe7:flag=4;ch=C;
break;
case 0xd7:flag=1;date=0;
break;
case 0xb7:flag=3;//ch==;
break;
case 0x77:flag=2;ch=+;
break;
}
if(temp!=0xf0)
{
delay(5);
temp=P1;
temp=temp&0xf0;
while(temp!=0xf0)//等待按鍵松開(kāi)
{
temp=P1;
temp=temp&0xf0;
}
}
}
}



關(guān)鍵詞: 單片機8位計算

評論


技術(shù)專(zhuān)區

關(guān)閉
国产精品自在自线亚洲|国产精品无圣光一区二区|国产日产欧洲无码视频|久久久一本精品99久久K精品66|欧美人与动牲交片免费播放
<dfn id="yhprb"><s id="yhprb"></s></dfn><dfn id="yhprb"><delect id="yhprb"></delect></dfn><dfn id="yhprb"></dfn><dfn id="yhprb"><delect id="yhprb"></delect></dfn><dfn id="yhprb"></dfn><dfn id="yhprb"><s id="yhprb"><strike id="yhprb"></strike></s></dfn><small id="yhprb"></small><dfn id="yhprb"></dfn><small id="yhprb"><delect id="yhprb"></delect></small><small id="yhprb"></small><small id="yhprb"></small> <delect id="yhprb"><strike id="yhprb"></strike></delect><dfn id="yhprb"></dfn><dfn id="yhprb"></dfn><s id="yhprb"><noframes id="yhprb"><small id="yhprb"><dfn id="yhprb"></dfn></small><dfn id="yhprb"><delect id="yhprb"></delect></dfn><small id="yhprb"></small><dfn id="yhprb"><delect id="yhprb"></delect></dfn><dfn id="yhprb"><s id="yhprb"></s></dfn> <small id="yhprb"></small><delect id="yhprb"><strike id="yhprb"></strike></delect><dfn id="yhprb"><s id="yhprb"></s></dfn><dfn id="yhprb"></dfn><dfn id="yhprb"><s id="yhprb"></s></dfn><dfn id="yhprb"><s id="yhprb"><strike id="yhprb"></strike></s></dfn><dfn id="yhprb"><s id="yhprb"></s></dfn>