|
有程序,有hex文件,有proteus仿真工程,還有原理圖。基于51單片機(jī)的智能路燈控制。
#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-);
}
|
|