导航: 老古网老古论坛XMOS公共讨论区XMOS开源项目区单片机程序设计嵌入式系统广告区域
→请大家帮忙看看这个程序哪里有问题谢谢了!

* 97727: 请大家帮忙看看这个程序哪里有问题谢谢了!

   yuyang813 
yuyang813发表的帖子 

 请大家帮忙看看这个程序哪里有问题谢谢了!
#include "reg51.h"
#define uint unsigned int
#define uchar unsigned char
#define Output  0xfe
#define Timer1 1000
#define Timer2 10000

/**********************************************
               延时程序
***********************************************/

void mDelay(uint Delay)
{ uint i;
  for(;Delay>  0;Delay--)
  { for(i=0;i  <124;i++)
      {;}
  
  }

}
/************************************************

                主程序
************************************************/
void main()
{ uint a[]={0x01,0x02};
  uint b[]={0x00,0x01,0x02,0x03};
  int  j;
  uint value;
  P2=0xFF;
while(1)
{ P1=a[0];   
  mDelay(Timer1);//延时1s
   value=P2;
     for(j=3;j>  =0;j--)
       if(value==b[j])
      {P3=0xfe;
    mDelay(Timer2);
      }
  mDelay(Timer2);
  P1=a[1]; 
  mDelay(Timer1);
  value=P2;
     for(j=3;j>  =0;j--)
       if(value==b[j])
       { P3=0xfe;
      mDelay(Timer2);
        }
   mDelay(Timer2);
 }
}

p2端口设置成为输入后,还是始终不能将输入值赋给value,从而使得后面得for循环、以及if比较程序不能正确执行,进而p3.0这个口所接得led无法亮,我也不知道是什么原因,还望大家指导一下,先谢谢了!!!




发表时间:2006年9月14日9:46:53

  
回复该帖

本主题共有 2 帖,分页:>>>>>该主题的所有内容[2]条

 *树形目录 只列出部分跟帖的标题以及简单的摘要信息 该主题的部分跟帖如下:

  97756.[详细]你的语句格式有错
摘要:#include "reg51.h" #define uint unsigned int #define uchar unsigned&nb......(1041字)
- [Kallor][1060次] 2006年9月14日

[上一篇帖子]:大家给俺推荐——DA转换器大家好!     &nbs
[下一篇帖子]:答复楼上的2412疑问1)LCD Controller STN LCD