求单片机交通灯的硬件电路图(ISIS)及程序,汇编语言
先看仿真效果图,源代码如下,我仿真可以的,电路图要的话发给你
#include<reg51.h>
#define uchar unsigned char
#define uint unsigned int
sbit RED_A=P0^0; //?﹁ボ?
sbit YELLOW_A=P0^1;
sbit GREEN_A=P0^2;
sbit RED_B=P0^3; //玭ボ?
sbit YELLOW_B=P0^4;
sbit GREEN_B=P0^5;
uchar Time_Count=0,Flash_Count=0,Operation_Type=1;
//﹚?竟 0 い?ㄧ?
void T0_INT() interrupt 1
{
TL0=-50000/256;
TH0=-50000%256;
switch(Operation_Type)
{
case 1: //?﹁??蒓玭??獹 5s
RED_A=0;
YELLOW_A=0;
GREEN_A=1;
RED_B=1;
YELLOW_B=0;
GREEN_B=0;
if(++Time_Count!=100) return; //5s100*50msち?
Time_Count=0;
Operation_Type=2; break;
case 2: //?﹁???﹍??????
if(++Time_Count!=8) return;
Time_Count=0;
YELLOW_A=~YELLOW_A;
GREEN_A=0;
if(++Flash_Count!=10) return; //??
Flash_Count=0;
Operation_Type=3; break;
case 3: //?﹁??蒓玭??獹 5s
RED_A=1;
YELLOW_A=0;
GREEN_A=0;
RED_B=0;
YELLOW_B=0;
GREEN_B=1;
if(++Time_Count!=100) return; //5s100*50msち?
Time_Count=0;
Operation_Type=4;
case 4: break; //玭???﹍??????
if(++Time_Count!=8) return;
Time_Count=0;
YELLOW_B=~YELLOW_B;GREEN_A=0;
if(++Flash_Count!=10) return; //??
Flash_Count=0;
Operation_Type=1; break;
}
}
//祘
void main()
{
TMOD=0x01;
IE=0x82;
TR0=1;
while(1);
}