当前位置:首页 > 技术学院 > 热搜器件
[导读]#include#include#define uint unsigned int#define uchar unsigned charuint date;uchar mm=0,n=0;uint k1,k2,k3,k4,k5,k6;uchar code b[]={0x3f,0x06,0x5b,0x4f,0x66, //0,1,2,3,4,0x6d,0x7d,0x07,0x7f,0x6f, //5,

#include

#include

#define uint unsigned int

#define uchar unsigned char

uint date;

uchar mm=0,n=0;

uint k1,k2,k3,k4,k5,k6;

uchar code b[]={

0x3f,0x06,0x5b,0x4f,0x66, //0,1,2,3,4,

0x6d,0x7d,0x07,0x7f,0x6f, //5,6,7,8,9,C

0xbf,0x86,0xdb,0xcf,0xe6, //0.,1.,2.,3.,4.,

0xed,0xfd,0x87,0xff,0xef, //5.,6.,7.,8.,9.,

};

sbit P20=P2^0;

sbit P21=P2^1;

sbit P22=P2^2;

sbit P27=P2^7;

sbit wr=P3^6;

sbit rd=P3^7;

sbit P32=P3^2;

void delay_10us(uchar n) //10微秒级延时

{ do

{ _nop_();

_nop_();

_nop_();

_nop_();

_nop_();

}while(--n);

}

void delay_ms(uint n) //毫秒级延时

{ do delay_10us(131);

while(--n);

}

uchar adc0809()

{

wr=0;

_nop_();

_nop_();

wr=1;

_nop_();

_nop_();

while(P32);

rd=0;

date=P0;

delay_10us(10);

rd=1;

delay_ms(1000);

date=date*19.607843;

//date=date*(1000/51);

n=0;

k1=date/1000;//1

k2=date%1000;//234

k3=k2/100;//2

k4=k2%100;//34

k5=k4/10;//3

k6=k4%10;//4

if(n==0)

{TI=0;

SBUF=b[k6];

while(!TI);

TI=0;

SBUF=b[k5];

while(!TI);

TI=0;

SBUF=b[k3];

while(!TI);

TI=0;

SBUF=b[k1+10];

while(!TI);

n=1;

}

}

void main()

{P0=0xff;

P20=0;

P21=0;

P22=0;

P27=0;

while(1)

{

adc0809();

}

}

本站声明: 本文章由作者或相关机构授权发布,目的在于传递更多信息,并不代表本站赞同其观点,本站亦不保证或承诺内容真实性等。需要转载请联系该专栏作者,如若文章内容侵犯您的权益,请及时联系本站删除( 邮箱:macysun@21ic.com )。
换一批
延伸阅读
关闭