標(biāo)題: 基于51單片機(jī)的交通燈設(shè)計 [打印本頁]

作者: 黑金山科技    時間: 2020-2-18 16:12
標(biāo)題: 基于51單片機(jī)的交通燈設(shè)計

#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;
void To_int()interrupt 1
{
  TH0=-50000/256;
  TL0=-50000%256;
  switch(Operation_Type)
  {
   case 1;
          RED_A=0;YELLOW_A=0;GREEN_A=l;
                  RED_B=l;YELLOW_B=0;GREEN_B=0;
                  if(++Time_Count!=100)
                   retun;
                  Time_ Count=0;
                  Operation_Type=2;
                  break;
   case 2:
       if(++Time_Count!=8)retun;
           Time_Count=0;
           YELLOW_A=!YELLOW_A;
           GREEN_A=0;
           if(++Flash_Count!=10)
           retun;
           Flash_ Count=0;
           Operation_Type=3;
           break;
void main()
{
TMOD=0x01;
IE=0x82;
TR0=l;
while(1);
}



放一下我的程序

新建文件夾.zip

20.65 KB, 下載次數(shù): 6, 下載積分: 黑幣 -5

hex文件。.c文件






歡迎光臨 (http://www.torrancerestoration.com/bbs/) Powered by Discuz! X3.1