A//D转换

#include
#include
#define uchar unsigned char 
#define uint unsigned int
sbit dula=P2^6;
sbit wela=P2^7;
sbit adwr=P3^6;
sbit adrd=P3^7;
uchar code table[]={
0x3f,0x06,0x5b,0x4f,0x66,
  0x6d,0x7d,0x07,0x7f,0x6f,
0x77,0x7c,0x39,0x5e,0x79,0x71
};
void delayms(uint xms)
{
uint i,j;
for(i=xms;i>0;i--)
for(j=100;j>0;j--);
}
void display(uchar bai,uchar shi,uchar ge)
{
dula = 1;
P0=table[bai];
dula = 0;
P0=0xff;
wela=1;
P0=0x7e;
wela=0;
delayms(5);

dula=1;
P0=table[shi];
dula=0;
P0=0xff;
wela=1;

你可能感兴趣的:(嵌入式入门)