|
有程序,有hex文件,有proteus仿真工程,还有原理图。基于51单片机的智能路灯控制。
#include<reg52.h>
void delay(unsigned long Dtime);
sbit L_Res=P0^5;
sbit Key1=P0^0;
sbit Key2=P0^1;
sbit Switch=P0^2;
sbit Led=P0^4;
main()
(
while(1)
(
while (Key1==0)//按键1按下,自动控制模式
{
if(L_Res==0)
{
Switch=1;
Led=Switch;
}
else
(
Switch=0;
Led=Switch;
)
}
if(Key2==0)
{
delay(2000);
if(Key2==0)
Switch=!Switch;
}
while(Key2==0);
}
}
}
void delay(unsigned long Dtime)
{
while(Dtime-);
}
|
|