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

 找回密碼
 立即注冊

QQ登錄

只需一步,快速開始

搜索
查看: 1975|回復(fù): 9
打印 上一主題 下一主題
收起左側(cè)

這個程序最后哪里有錯啊?第一次弄不懂

[復(fù)制鏈接]
跳轉(zhuǎn)到指定樓層
樓主
ID:617359 發(fā)表于 2019-9-27 20:30 | 只看該作者 回帖獎勵 |倒序瀏覽 |閱讀模式
#include<reg52.h>
#define uchar unsigned char
#define uint unsigned int

uchar code tab[10]={0x3f,0x06,0x5b,0x4f,0x66,0x6d,0x7d,0x07,0x7f,0x6f};

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;
uchar num=0;
Operation_Type=1;
void DelayMS(uint x);

void Traffic_light()
{
   switch(Operation_Type)
   {
     case 1:
           RED_A=1;YELLOW_A=1;GREEN_A=0;
           RED_B=0;YELLOW_B=1;GREEN_B=1;
           Operation_Type=2;
           for(num=9;num>2;--num)
           {
              P1=tab[num];
                  DelayMS(1000);
           }
           break;
         case 2:
           for(Flash_Count=1;Flash_Count<=10;Flash_Count++)
           {   
             P1=tab[num];
                 DelayMS(200);
                 YELLOW_A=~YELLOW_A;
                 if(Flash_Count%5==0)num--;
           }
           Operation_Type=3;
           break;
         case 3:
           RED_A=0;YELLOW_A=1;GREEN_A=1;
           RED_B=1;YELLOW_B=1;GREEN_B=0;
           for(num=7;num>0;num--)
       {
             P1=tab[num];
                 DelayMS(1000);
           }
           Operation_Type=4;
           break;
         case 4:
           num=2;
           for(Flash_Count=1;Flash_Count<=10;Flash_Count++)
           {
             P1=tab[num];
                 DelayMS(200);
                 YELLOW_B=~YELLOW_B;
                 if(Flash_Count%5==0)num--;
           }
           Operation_Type=1;
           break;
        }
}
void main()
{
   while(1)
{
     Traffic_lignt ();
   }
}

分享到:  QQ好友和群QQ好友和群 QQ空間QQ空間 騰訊微博騰訊微博 騰訊朋友騰訊朋友
收藏收藏 分享淘帖 頂 踩
回復(fù)

使用道具 舉報

沙發(fā)
ID:351097 發(fā)表于 2019-9-27 22:23 | 只看該作者
Operation_Type這個變量沒有定義?
回復(fù)

使用道具 舉報

板凳
ID:453974 發(fā)表于 2019-9-27 23:25 | 只看該作者
第一個問題是你 Traffic_lignt ();抄錯了,第二個問題是void DelayMS(uint x);這個沒寫子函數(shù)
回復(fù)

使用道具 舉報

地板
ID:453974 發(fā)表于 2019-9-27 23:26 | 只看該作者
#include<reg52.h>
#define uchar unsigned char
#define uint unsigned int

uchar code tab[10]={0x3f,0x06,0x5b,0x4f,0x66,0x6d,0x7d,0x07,0x7f,0x6f};

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;
uchar num=0;
Operation_Type=1;
void DelayMS(uint x);

void Traffic_light()
{
   switch(Operation_Type)
   {
     case 1:
           RED_A=1;YELLOW_A=1;GREEN_A=0;
           RED_B=0;YELLOW_B=1;GREEN_B=1;
           Operation_Type=2;
           for(num=9;num>2;--num)
           {
              P1=tab[num];
                  DelayMS(1000);
           }
           break;
         case 2:
           for(Flash_Count=1;Flash_Count<=10;Flash_Count++)
           {   
             P1=tab[num];
                 DelayMS(200);
                 YELLOW_A=~YELLOW_A;
                 if(Flash_Count%5==0)num--;
           }
           Operation_Type=3;
           break;
         case 3:
           RED_A=0;YELLOW_A=1;GREEN_A=1;
           RED_B=1;YELLOW_B=1;GREEN_B=0;
           for(num=7;num>0;num--)
       {
             P1=tab[num];
                 DelayMS(1000);
           }
           Operation_Type=4;
           break;
         case 4:
           num=2;
           for(Flash_Count=1;Flash_Count<=10;Flash_Count++)
           {
             P1=tab[num];
                 DelayMS(200);
                 YELLOW_B=~YELLOW_B;
                 if(Flash_Count%5==0)num--;
           }
           Operation_Type=1;
           break;
        }
}
void main()
{
   while(1)
{
     Traffic_light ();
   }
}
void DelayMS(uint x)
{
        for(x=0;x<1000;x++)
        {
       
        }
}
回復(fù)

使用道具 舉報

5#
ID:149144 發(fā)表于 2019-9-27 23:28 | 只看該作者

Operation_Type 沒有定義
有效行 第 13 行  Operation_Type=1;
改為 unsigned char Operation_Type=1;
或    uchar Operation_Type=1;
回復(fù)

使用道具 舉報

6#
ID:235200 發(fā)表于 2019-9-28 02:13 | 只看該作者
要說明什么錯誤現(xiàn)象呀
回復(fù)

使用道具 舉報

7#
ID:213173 發(fā)表于 2019-9-28 05:19 | 只看該作者
錯誤1.主函數(shù)調(diào)用的子函數(shù)Traffic_lignt ();與實際子函數(shù)Traffic_light()不同名
錯誤2.延時函數(shù)只聲明了函數(shù)名,沒有函數(shù)體
void DelayMS(uint x)
{
        uint i,j;
        for(i=0;i<x;i++)
                for(j=0;j<125;j++);
}
回復(fù)

使用道具 舉報

8#
ID:155507 發(fā)表于 2019-9-28 07:04 | 只看該作者
給你改了,對比一下就知道哪里錯了。

  1. #include <reg52.h>
  2. #define uchar unsigned char
  3. #define uint unsigned int

  4. uchar code tab[10]={0x3f,0x06,0x5b,0x4f,0x66,0x6d,0x7d,0x07,0x7f,0x6f};

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

  11. uchar Flash_Count=0;
  12. uchar num=0;
  13. uchar Operation_Type=1;
  14. void DelayMS(uint z)
  15. {
  16.         uint x,y;
  17.         for(x=z;x>0;x--)
  18.            for(y=110;y>0;y--);
  19. }

  20. void Traffic_light()
  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.                 Operation_Type=2;
  28.                 for(num=9;num>2;--num)
  29.                 {
  30.                         P1=tab[num];
  31.                         DelayMS(1000);
  32.                 }
  33.                 break;
  34.         case 2:
  35.                 for(Flash_Count=1;Flash_Count<=10;Flash_Count++)
  36.                 {   
  37.                         P1=tab[num];
  38.                         DelayMS(200);
  39.                         YELLOW_A=~YELLOW_A;
  40.                         if(Flash_Count%5==0)num--;
  41.                 }
  42.                 Operation_Type=3;
  43.                 break;
  44.         case 3:
  45.                 RED_A=0;YELLOW_A=1;GREEN_A=1;
  46.                 RED_B=1;YELLOW_B=1;GREEN_B=0;
  47.                 for(num=7;num>0;num--)
  48.                 {
  49.                         P1=tab[num];
  50.                         DelayMS(1000);
  51.                 }
  52.                 Operation_Type=4;
  53.                 break;
  54.         case 4:
  55.                 num=2;
  56.                 for(Flash_Count=1;Flash_Count<=10;Flash_Count++)
  57.                 {
  58.                         P1=tab[num];
  59.                         DelayMS(200);
  60.                         YELLOW_B=~YELLOW_B;
  61.                         if(Flash_Count%5==0)num--;
  62.                 }
  63.                 Operation_Type=1;
  64.                 break;
  65.         }
  66. }

  67. void main()
  68. {
  69.         while(1)
  70.         {
  71.                 Traffic_light(); //Traffic_lignt ();
  72.         }
  73. }


復(fù)制代碼
回復(fù)

使用道具 舉報

9#
ID:466578 發(fā)表于 2019-9-28 08:25 | 只看該作者
帶倒計時的交通信號燈程序
不過沒明白你說的錯是什么
回復(fù)

使用道具 舉報

10#
ID:617497 發(fā)表于 2019-9-28 10:49 | 只看該作者
時序不清晰
回復(fù)

使用道具 舉報

您需要登錄后才可以回帖 登錄 | 立即注冊

本版積分規(guī)則

小黑屋|51黑電子論壇 |51黑電子論壇6群 QQ 管理員QQ:125739409;技術(shù)交流QQ群281945664

Powered by 單片機教程網(wǎng)

快速回復(fù) 返回頂部 返回列表