久久久久久久999_99精品久久精品一区二区爱城_成人欧美一区二区三区在线播放_国产精品日本一区二区不卡视频_国产午夜视频_欧美精品在线观看免费

 找回密碼
 立即注冊(cè)

QQ登錄

只需一步,快速開(kāi)始

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

這個(gè)程序最后哪里有錯(cuò)啊?第一次弄不懂

[復(fù)制鏈接]
跳轉(zhuǎn)到指定樓層
樓主
ID:617359 發(fā)表于 2019-9-27 20:30 | 只看該作者 回帖獎(jiǎng)勵(lì) |倒序?yàn)g覽 |閱讀模式
#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ù)

使用道具 舉報(bào)

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

使用道具 舉報(bào)

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

使用道具 舉報(bào)

地板
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ù)

使用道具 舉報(bào)

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

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

使用道具 舉報(bào)

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

使用道具 舉報(bào)

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

使用道具 舉報(bào)

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

  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ù)

使用道具 舉報(bào)

9#
ID:466578 發(fā)表于 2019-9-28 08:25 | 只看該作者
帶倒計(jì)時(shí)的交通信號(hào)燈程序
不過(guò)沒(méi)明白你說(shuō)的錯(cuò)是什么
回復(fù)

使用道具 舉報(bào)

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

使用道具 舉報(bào)

本版積分規(guī)則

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

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

快速回復(fù) 返回頂部 返回列表
主站蜘蛛池模板: av在线天天 | 欧美精品一区二区三区蜜臀 | 亚洲高清在线观看 | 粉嫩国产精品一区二区在线观看 | 欧美国产视频 | 亚洲小视频在线播放 | 一区二区三区中文字幕 | 国产永久免费 | 日韩另类视频 | 91av在线看 | 免费在线观看黄网站 | 国外成人在线视频 | 欧美在线一区二区三区 | 日本高清中文字幕 | 亚洲成人日韩 | 久在线视频 | 午夜亚洲 | 亚洲精品欧美一区二区三区 | 亚洲毛片在线观看 | 久久精品国产一区二区 | 天天干成人网 | 日韩欧美三区 | 日韩中文字幕在线视频 | 久久久www成人免费精品 | 91嫩草精品 | 一区日韩 | 在线观看av网站永久 | 日本精品一区二区 | 91精品在线播放 | 福利视频一二区 | 国产激情一区二区三区 | 天堂一区二区三区四区 | 毛片1 | 日本久久一区 | 国产91久久精品一区二区 | 国产精品免费一区二区三区四区 | 国产亚洲精品美女久久久久久久久久 | 欧美日韩一区在线 | 天堂在线www | 在线视频第一页 | 四虎午夜剧场 |