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

QQ登錄

只需一步,快速開始

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

幫我看看我的程序那里錯(cuò)了

[復(fù)制鏈接]
跳轉(zhuǎn)到指定樓層
樓主
ID:45218 發(fā)表于 2012-10-4 10:23 | 只看該作者 回帖獎(jiǎng)勵(lì) |倒序?yàn)g覽 |閱讀模式
#define uint unsigned int #define uchar unsigned char uchar temp; void delay(); void main() { while(1) temp=0xfe; P1=temp; { temp= _crol_ (temp,1); delay(); P1=temp; } } void delay() { uint x,y; for(x=100;x>0;x--) for(y=100;y>0;y--); }
分享到:  QQ好友和群QQ好友和群 QQ空間QQ空間 騰訊微博騰訊微博 騰訊朋友騰訊朋友
收藏收藏 分享淘帖 頂 踩
回復(fù)

使用道具 舉報(bào)

沙發(fā)
ID:45218 發(fā)表于 2012-10-4 10:23 | 只看該作者
#define uint unsigned int
#define uchar unsigned char
uchar temp;
void delay();
void main()
{
 while(1)
  temp=0xfe;
  P1=temp;
  {
   temp= _crol_ (temp,1);
   delay();
   P1=temp; 
  }
}
void delay()
{
 uint x,y;
 for(x=100;x>0;x--)
  for(y=100;y>0;y--);
}
回復(fù)

使用道具 舉報(bào)

板凳
ID:45218 發(fā)表于 2012-10-4 14:38 | 只看該作者

我就不知道自己錯(cuò)在哪里這么回事呀。!

希望大師傅們教我。!

#define uint unsigned int
#define uchar unsigned char
uchar temp;
void delay();
void main()
{
 while(1)
  temp=0xfe;
  P1=temp;
  {
   temp= _crol_ (temp,1);
   delay();
   P1=temp; 
  }
}
void delay()
{
 uint x,y;
 for(x=100;x>0;x--)
  for(y=100;y>0;y--);
}

回復(fù)

使用道具 舉報(bào)

地板
ID:45200 發(fā)表于 2012-10-4 15:21 | 只看該作者

你是要做跑馬燈吧

我在你的程序上修改了下:

#include<intrins.h>

#define uint unsigned int
#define uchar unsigned char
uchar temp;
void delay();
void main()
{
 
  temp=0xfe;
  P1=temp;
  while(1)
  {
   temp= _crol_ (temp,1);
   delay();
   P1=temp;
  }
}
void delay()
{
 uint x,y;
 for(x=100;x>0;x--)
  for(y=100;y>0;y--);
}
運(yùn)行過的,可以用的。

回復(fù)

使用道具 舉報(bào)

5#
ID:45200 發(fā)表于 2012-10-4 15:23 | 只看該作者

#include<reg51.h>

少了上面這個(gè)頭文件!

回復(fù)

使用道具 舉報(bào)

6#
ID:45218 發(fā)表于 2012-10-5 09:01 | 只看該作者

非常感謝,我是初學(xué)單片機(jī)很多地方都不是很明白。希望能和各位師傅們常交流!!

回復(fù)

使用道具 舉報(bào)

7#
ID:37087 發(fā)表于 2012-10-13 10:48 | 只看該作者
while錯(cuò)了,你這樣寫是個(gè)死循環(huán)。
回復(fù)

使用道具 舉報(bào)

本版積分規(guī)則

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

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

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