|
僅供學習使用 不得商用
#include <reg52.h>
#include "ds18b20.h"
//òy½Å¶¨òå:
sbit SMG_q = P0^0;
sbit SMG_b = P0^1;
sbit SMG_s = P0^2;
sbit SMG_g = P0^3;
unsigned char ly_dis[4];
code unsigned char table[]={0xc0,0xf9,0xa4,0xb0,0x99,0x92,0x82,0xf8,0x80,0x90,0xc6};
unsigned char l_posit=0;
void display(void)
void delay(void);
void main()
{
unsigned int i=0;
char ltemp;
while(1){
if(i==0)
tmpchange();
if(i==100){
ltemp=tmp()/16;
if(ltemp<0){
ly_dis[0]=0xbf;
ltemp=0-ltemp;
}
else
ly_dis[0]=ltemp/100;
ltemp=ltemp%100;
ly_dis[1]=ltemp/10;
ly_dis[2]=ltemp%10;
ly_dis[3]=10;
}
i++;
if(i==3000)
i=0;
display();
delay();
}
}
void display()
{
P2=0XFF;
switch(l_posit){
case 0:
SMG_q=0;
SMG_b=1;
SMG_s=1;
SMG_g=1;
P2=table[ly_dis[0]];
break;
case 1:
SMG_q=1;
SMG_b=0;
SMG_s=1;
SMG_g=1;
P2=table[ly_dis[1]];
break;
case 2:
SMG_q=1;
SMG_b=1;
SMG_s=0;
SMG_g=1;
P2=table[ly_dis[2]];
break;
case 3:
SMG_q=1;
SMG_b=1;
SMG_s=1;
SMG_g=0;
P2=table[ly_dis[3]];
break;
}
l_posit++;
if(l_posit>3)
l_posit=0;
}
//Ñóê±×óoˉêy,¶ìÔYÑóê±
void delay(void){
unsigned char i=10;
while(i--);
}
|
|