资源简介
LED模拟交通灯程序代码,可以用记事本直接打开,也可以直接编译后使用。
代码片段和文件信息
//-----------------------------------
//名称:LED模拟交通灯
//----------------------------------
//说明:东西向绿灯亮若干秒后,黄灯闪烁,闪烁5次后亮红灯,红灯亮后,南北向由红灯变为绿灯,若干秒后南北向黄灯闪烁,闪烁5次后亮红灯,东西向绿灯亮,如此重复。
//-----------------------------------
#include
#include
#define uchar unsigned char
#define uint unsigned int
sbit RED_A=P1^0;
sbit YELLOW_A=P1^1;
sbit GREEN_A=P1^2;
sbit RED_B=P1^3;
sbit YELLOW_B=P1^4;
sbit GREEN_B=P1^5;
uchar Flash_Count=0;
Operation_Type=1;
//-----------------------
//延时
//-------------------------
void DelayMS(uint x)
{
uchar t;
while(x--)
{
for(t=0;t<120;t++);
}
}
//----------------------------------
//交通灯切换子程序
//-------------------------------------
void Traffic_Light()
{
switch(Operation_Type)
{
case 1://东西向绿灯与南北向红灯亮
- 上一篇:1602程序大全
- 下一篇:solidcam后处理文件
评论
共有 条评论