#include<reg52.h>
#define uchar unsigned char
#define uint unsigned int
sbit sda=P2^0;
sbit scl=P2^1;
sbit dula=P2^6;
sbit wela=P2^7;
uchar flag,sec;
uint num;
uchar code table[]={
0x3f,0x06,0x5b,0x4f,
0x66,0x6d,0x7d,0x07,
0x7f,0x6f,//0x77,0x7c,
//0x39,0x5e,0x79,0x71
};
void delay()
{ ;; }
void start() //開始訊號
{
sda=1;
delay();
scl=1;
sda=0;
}
void stop() //停止
void respons() //應答
uchar i=0;
while((sda==1)&&(i<250))i++;
scl=0;
void init()
void write_byte(uchar date)
uchar i,temp;
temp=date;
for(i=0;i<8;i++)
temp=temp<<1;
sda=CY;
uchar read_byte()
uchar i,k;
k=(k<<1)|sda;
return k;
void delayms(uchar x)
uchar a,b;
for(a=x;a>0;a--)
for(b=110;b>0;b
#include<reg52.h>
#define uchar unsigned char
#define uint unsigned int
sbit sda=P2^0;
sbit scl=P2^1;
sbit dula=P2^6;
sbit wela=P2^7;
uchar flag,sec;
uint num;
uchar code table[]={
0x3f,0x06,0x5b,0x4f,
0x66,0x6d,0x7d,0x07,
0x7f,0x6f,//0x77,0x7c,
//0x39,0x5e,0x79,0x71
};
void delay()
{ ;; }
void start() //開始訊號
{
sda=1;
delay();
scl=1;
delay();
sda=0;
delay();
}
void stop() //停止
{
sda=0;
delay();
scl=1;
delay();
sda=1;
delay();
}
void respons() //應答
{
uchar i=0;
scl=1;
delay();
while((sda==1)&&(i<250))i++;
scl=0;
delay();
}
void init()
{
sda=1;
delay();
scl=1;
delay();
}
void write_byte(uchar date)
{
uchar i,temp;
temp=date;
scl=0;
for(i=0;i<8;i++)
{
temp=temp<<1;
delay();
sda=CY;
delay();
scl=1;
delay();
scl=0;
delay();
}
sda=1;
delay();
}
uchar read_byte()
{
uchar i,k;
scl=0;
delay();
sda=1;
delay();
for(i=0;i<8;i++)
{
scl=1;
delay();
k=(k<<1)|sda;
scl=0;
delay();
}
return k;
}
void delayms(uchar x)
{
uchar a,b;
for(a=x;a>0;a--)
for(b=110;b>0;b