打印

51单片机c语言流水灯单次循环程序怎么编写啊

[复制链接]
3062|8
手机看帖
扫描二维码
随时随地手机跟帖
跳转到指定楼层
楼主
614325|  楼主 | 2013-3-17 21:29 | 只看该作者 回帖奖励 |倒序浏览 |阅读模式
沙发
zhangbtj| | 2013-3-17 21:33 | 只看该作者
弄个条件循环,设个变量设置循环次数,跳出就OK了

使用特权

评论回复
板凳
614325|  楼主 | 2013-3-17 22:00 | 只看该作者
#define uint unsigned int
#define uchar unsigned char
void delay(uint);
uchar temp;
void main()
{
  P1=0xfe;
        P1=0xff;

       
        temp=0xfe;
  while (P1!=0x7f)
  {
                temp=_crol_(temp,1);
                delay(100);
                P1=temp;
        }       



}
void delay(uint z)
{

        uint x,y;
        for(x=z;x>0;x--)
          for(y=500;y>0;y--);
}

这个程序为什么第一个灯不亮呢怎么改压

使用特权

评论回复
地板
614325|  楼主 | 2013-3-17 22:02 | 只看该作者
#include<reg52.h>
#include <intrins.h>
#define uint unsigned int
#define uchar unsigned char
void delay(uint);
uchar temp;
void main()
{


       
        temp=0xfe;
  while (P1!=0x7f)
  {
                temp=_crol_(temp,1);
                delay(100);
                P1=temp;
        }       



}
void delay(uint z)
{

        uint x,y;
        for(x=z;x>0;x--)
          for(y=500;y>0;y--);
}
是这个不是上面那个

使用特权

评论回复
5
614325|  楼主 | 2013-3-17 22:30 | 只看该作者
有人懂么

使用特权

评论回复
6
sin0725| | 2013-3-17 23:27 | 只看该作者
是不是第一个灯跟第二个灯之间的延时太短了

使用特权

评论回复
7
nano313| | 2013-3-18 00:13 | 只看该作者
#include<reg52.h>
#include <intrins.h>
#define uint unsigned int
#define uchar unsigned char
void delay(uint);
uchar temp;
void main()
{      
temp=0xfe;
  while (P1!=0x7f)
  {
   P0=temp;
   delay(100);
   temp=_crol_(temp,1);
  }        
}
void delay(uint z)
{
uint x,y;
  for(x=z;x>0;x--)
   for(y=500;y>0;y--);
}
先让灯亮一会再作移位

使用特权

评论回复
8
614325|  楼主 | 2013-3-18 15:54 | 只看该作者
谢谢,问题已经解决啦,最后在放一个while(1)的死好啦

使用特权

评论回复
9
IC采购哪里去| | 2013-3-18 16:41 | 只看该作者
这个我见过,我们大学时候考试就考这个,不过现在是真心想不起来了,但是知道流水灯是怎么回事!嘿嘿!

使用特权

评论回复
发新帖 我要提问
您需要登录后才可以回帖 登录 | 注册

本版积分规则

6

主题

15

帖子

0

粉丝