欧美极品高清xxxxhd,国产日产欧美最新,无码AV国产东京热AV无码,国产精品人与动性XXX,国产传媒亚洲综合一区二区,四库影院永久国产精品,毛片免费免费高清视频,福利所导航夜趣136
標(biāo)題:
為什么lcd沒有顯示,數(shù)碼管也是亂碼 求大神指導(dǎo)
[打印本頁]
作者:
qqqwer。
時(shí)間:
2019-2-27 19:51
標(biāo)題:
為什么lcd沒有顯示,數(shù)碼管也是亂碼 求大神指導(dǎo)
為什么lcd沒有顯示,數(shù)碼管也是亂碼
#include<reg52.h>
#include "keyboard.h"
#include "delay1.h"
#include "1602.h"
#include "ds1302.h"
#include "ds18b20.h"
#include "temp.h"
#define uchar unsigned char
#define uint unsigned int
#define led P2
sbit beep=P1^5;
sbit LSA=P2^2;
sbit LSB=P2^3;
sbit LSC=P2^4;
char num=0;
uchar DisplayData[8];
uchar code smgduan[10]={0x3f,0x06,0x5b,0x4f,0x66,0x6d,0x7d,0x07,0x7f,0x6f};
uchar DisplayData1[9];
uchar code smgduan1[10]={0x3f,0x06,0x5b,0x4f,0x66,0x6d,0x7d,0x07,0x7f,0x6f};
uchar password[4]={1,0,0,0};
uchar userpassword[4];
void datapros1(int temp)
{
float tp;
if(temp< 0) //當(dāng)溫度值為負(fù)數(shù)
{
DisplayData1[0] = 0x40; // -
//因?yàn)樽x取的溫度是實(shí)際溫度的補(bǔ)碼,所以減1,再取反求出原碼
temp=temp-1;
temp=~temp;
tp=temp;
temp=tp*0.0625*100+0.5;
//留兩個(gè)小數(shù)點(diǎn)就*100,+0.5是四舍五入,因?yàn)镃語言浮點(diǎn)數(shù)轉(zhuǎn)換為整型的時(shí)候把小數(shù)點(diǎn)
//后面的數(shù)自動(dòng)去掉,不管是否大于0.5,而+0.5之后大于0.5的就是進(jìn)1了,小于0.5的就
//算加上0.5,還是在小數(shù)點(diǎn)后面。
}
else
{
DisplayData1[0] = 0x00;
tp=temp;//因?yàn)閿?shù)據(jù)處理有小數(shù)點(diǎn)所以將溫度賦給一個(gè)浮點(diǎn)型變量
//如果溫度是正的那么,那么正數(shù)的原碼就是補(bǔ)碼它本身
temp=tp*0.0625*100+0.5;
//留兩個(gè)小數(shù)點(diǎn)就*100,+0.5是四舍五入,因?yàn)镃語言浮點(diǎn)數(shù)轉(zhuǎn)換為整型的時(shí)候把小數(shù)點(diǎn)
//后面的數(shù)自動(dòng)去掉,不管是否大于0.5,而+0.5之后大于0.5的就是進(jìn)1了,小于0.5的就
//算加上0.5,還是在小數(shù)點(diǎn)后面。
}
DisplayData1[1] = smgduan1[temp / 10000];
DisplayData1[2] = smgduan1[temp % 10000 / 1000];
DisplayData1[3] = 0x2e;
DisplayData1[4] = smgduan1[temp % 100 / 10];
DisplayData1[5] = smgduan1[temp % 10];
}
void datapros()
{
Ds1302ReadTime();
DisplayData[0] = smgduan[TIME[2]/16]; //時(shí)
DisplayData[1] = smgduan[TIME[2]&0x0f];
DisplayData[2] = 0x40;
DisplayData[3] = smgduan[TIME[1]/16]; //分
DisplayData[4] = smgduan[TIME[1]&0x0f];
DisplayData[5] = 0x40;
DisplayData[6] = smgduan[TIME[0]/16]; //秒
DisplayData[7] = smgduan[TIME[0]&0x0f];
}
void delay(uint i)
{
while(i--);
}
void DigDisplay()
{
uchar i;
for(i=0;i<8;i++)
{
switch(i) //位選,選擇點(diǎn)亮的數(shù)碼管,
{
case(0):
LSA=0;LSB=0;LSC=0; break;//顯示第0位
case(1):
LSA=1;LSB=0;LSC=0; break;//顯示第1位
case(2):
LSA=0;LSB=1;LSC=0; break;//顯示第2位
case(3):
LSA=1;LSB=1;LSC=0; break;//顯示第3位
case(4):
LSA=0;LSB=0;LSC=1; break;//顯示第4位
case(5):
LSA=1;LSB=0;LSC=1; break;//顯示第5位
case(6):
LSA=0;LSB=1;LSC=1; break;//顯示第6位
case(7):
LSA=1;LSB=1;LSC=1; break;//顯示第7位
}
P0=DisplayData[7-i];//發(fā)送數(shù)據(jù)
delay(100); //間隔一段時(shí)間掃描
P0=0x00;//消隱
}
}
void buzzer()
{
beep=0;
Delayms(100);
beep=1;
}
void lw()
{
uint i;
led=0xfe;
delay(50000);
for(i=0;i<7;i++) //將led左移一位
{
led=_crol_(led,1);
delay(50000); //大約延時(shí)450ms
}
for(i=0;i<7;i++) //將led右移一位
{
led=_cror_(led,1);
delay(50000); //大約延時(shí)450ms
}
}
void user_password()
{
uint i,n=0,key=0;
for(i=0;i<4;i++)
{
if(KeyPro()!=0xff)
{
Delayms(5);
if(KeyPro()!=0xff)
{
userpassword[i]=KeyPro();
}
while(KeyPro()!=0xff);
}
}
for(i=0;i<4;i++)
{
if(userpassword[i]==password[i])
{
Delayms(5);
if(userpassword[i]==password[i])
{
key++;
}
}
}
if(key==4)
{
buzzer();
n++;
}
else
{
lw();
n=0;
}
}
void admin_password()
{
uint i,j,t=0;
for(i=0;i<4;)
{
if(userpassword[i]=='/')
{
Delayms(10);
if(userpassword[i]=='/')
{
t++;
}
}
}
if(t==4)
{
for(j=0;j<4;j++)
{
password[j]=KeyPro();
}
}
}
void main()
{
uint num;
Ds1302Init();
LCD_Init();
while(1)
{
user_password();
admin_password();
datapros(); //數(shù)據(jù)處理函數(shù)
DigDisplay();
datapros1(Ds18b20ReadTemp()); //數(shù)據(jù)處理函數(shù)
LCD_Write_Com(0x80);
for(num=0;num<9;num++)
{
LCD_Write_Data(DisplayData1[num]);
Delayms(5);
}
}
}
復(fù)制代碼
歡迎光臨 (http://www.raoushi.com/bbs/)
Powered by Discuz! X3.1