1024手机基地看电影,午夜福利视频导航,国产精品福利在线一区,亚洲欧美日韩另类成人,在线观看午夜日本理论片,成年超爽免费网站,国产精品成人免费,精品动作一级毛片,成人免费观看网站,97精品伊人久久大香蕉

標題: LED模擬交通燈 [打印本頁]

作者: 清風兌酒    時間: 2018-12-21 18:35
標題: LED模擬交通燈
本帖最后由 清風兌酒 于 2018-12-22 23:33 編輯

[attach]162988[/attach][attach]162988[/attach]附件里有仿真和源程序


#include <reg52.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 Flash_Count = 0;
Operation_Type = 1;

void DelayMS(uint x)
{
         uchar t;
        while(x--)
        {
                 for(t=120;t>0;t--);
        }
}

void Traffic_lignt()
{
         switch(Operation_Type)
        {
                 case 1:
                        RED_A=1;YELLOW_A=1;GREEN_A=0;
                        RED_B=0;YELLOW_B=1;GREEN_B=1;
                        DelayMS(5000);
                        Operation_Type = 2;
                        break;
                case 2:
                        DelayMS(500);
                        YELLOW_A=~YELLOW_A;
                        if(++Flash_Count !=10)
                                return;
                        Flash_Count=0;
                        Operation_Type = 3;
                        break;
                case 3:
                        RED_A=0;YELLOW_A=1;GREEN_A=1;
                        RED_B=1;YELLOW_B=1;GREEN_B=0;
                        DelayMS(5000);
                        Operation_Type = 4;
                        break;        
                case 4:
                        DelayMS(500);
                        YELLOW_B=~YELLOW_B;
                        if(++Flash_Count !=10)
                                return;
                        Flash_Count=0;
                        Operation_Type = 1;
                        break;        
        }
}

void main()
{
         while(1)
        {
                 Traffic_lignt();        
        }
}

QQ截圖20181221182513.png (47.05 KB, 下載次數(shù): 38)

QQ截圖20181221182513.png

QQ截圖20181221182435.png (47.74 KB, 下載次數(shù): 45)

QQ截圖20181221182435.png

QQ截圖20181222233210.png (3.95 KB, 下載次數(shù): 34)

QQ截圖20181222233210.png

05 LED模擬交通燈.rar

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






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