欧美极品高清xxxxhd,国产日产欧美最新,无码AV国产东京热AV无码,国产精品人与动性XXX,国产传媒亚洲综合一区二区,四库影院永久国产精品,毛片免费免费高清视频,福利所导航夜趣136

標題: 單片機LED模擬交通燈Proteus仿真代碼 [打印本頁]

作者: A2102179814    時間: 2022-4-28 15:02
標題: 單片機LED模擬交通燈Proteus仿真代碼
仿真原理圖如下(proteus仿真工程文件可到本帖附件中下載)


單片機源程序如下:
  1. #include <reg52.h>
  2. #define uchar unsigned char
  3. #define uint unsigned int

  4. sbit RED_A=P0^0;
  5. sbit YELLOW_A=P0^1;
  6. sbit GREEN_A=P0^2;
  7. sbit RED_B=P0^3;
  8. sbit YELLOW_B=P0^4;
  9. sbit GREEN_B=P0^5;

  10. uchar Flash_Count = 0;
  11. Operation_Type = 1;

  12. void DelayMS(uint x)
  13. {
  14.         uchar t;
  15.         while(x--)
  16.         {
  17.                  for(t=120;t>0;t--);
  18.         }
  19. }

  20. void Traffic_lignt()
  21. {
  22.         switch(Operation_Type)
  23.         {
  24.                  case 1:
  25.                         RED_A=1;YELLOW_A=1;GREEN_A=0;
  26.                         RED_B=0;YELLOW_B=1;GREEN_B=1;
  27.                         DelayMS(2000);
  28.                         Operation_Type = 2;
  29.                         break;
  30.                 case 2:
  31.                         DelayMS(200);
  32.                         YELLOW_A=~YELLOW_A;
  33.                         if(++Flash_Count !=10)
  34.                                 return;
  35.                         Flash_Count=0;
  36.                         Operation_Type = 3;
  37.                         break;
  38.                 case 3:
  39.                         RED_A=0;YELLOW_A=1;GREEN_A=1;
  40.                         RED_B=1;YELLOW_B=1;GREEN_B=0;
  41.                         DelayMS(2000);
  42.                         Operation_Type = 4;
  43.                         break;      
  44.                 case 4:
  45.                         DelayMS(200);
  46.                         YELLOW_B=~YELLOW_B;
  47.                         if(++Flash_Count !=10)
  48.                                 return;
  49.                         Flash_Count=0;
  50.                         Operation_Type = 1;
  51.                         break;      
  52.         }
  53. }

  54. void main()
  55. {
  56.         while(1)
  57.         {
  58.                  Traffic_lignt();      
  59.         }
  60. }
復制代碼

Keil代碼與Proteus仿真下載: LED模擬交通燈.7z (44.43 KB, 下載次數(shù): 62)

作者: gzn    時間: 2023-7-1 10:51
請問這個需要分時控制嗎

作者: 15699183053    時間: 2023-7-23 12:12
非常感謝,很需要這方面的資料,,,,




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