基于51单片机和Proteus仿真含代码和仿真图的路灯自动控制系统(光控)

代码如下:

#include
sbit LED=P2^4;
sbit k1=P1^7;
#include
#define uchar unsigned char
#define uint unsigned int
uchar code table[]={0xc0,0xf9,0xa4,0xb0,0x99,0x92,0x82,0xf8,0x80,0x90};//共阳极
sbit EOC=P2^0;
sbit OE=P2^1;
sbit ST=P2^2;
sbit clock=P2^3;
sbit ADD_C=P2^5;
sbit ADD_B=P2^6;
sbit ADD_A=P2^7;
sbit dot=P3^7;
uint disbuff[4];
uint T;
uchar S,M,H;
void delay(int x)//延时函数
{
    unsigned char a,b;
    for(a=0;a     for(b=0;b<120;b++);
}

void T0_clock() interrupt 1
{
 clock=~clock;
}
void init()
{
  TMOD=0x02;
  TH0=TL0=236;
  EA=1;ET0=1;TR0=1;//T0工作方式初值256-20
}
//void display0()               //数码管

你可能感兴趣的:(单片机,Proteus,c语言)