这个程序有啥问题?实现C51单片机流水灯的设计

[复制链接]
查看11 | 回复5 | 2011-4-6 11:46:23 | 显示全部楼层 |阅读模式
#includereg51.h
#define uchar unsigned char
#define uint unsigned int
void Delays(uint x)
{

uint i,,j;
for(i=x;i0;i--)
for(j=110;j0;j--);
}
void main(void)
{
uchar led=0xFE;
while(1)
{P1=led;
led=lift_func (led);
Delays(300);
}
}
uchar lift_four(uchar led)
{
uchar result;
result=(led7)|(led1);
return result;
}
回复

使用道具 举报

千问 | 2011-4-6 11:46:23 | 显示全部楼层
<pre id=\"best-answer-content\" class=\"reply-text mb10\">应该可以改成这样,调试过,没问题
#includereg51.h
#define uchar unsigned char
#define uint unsigned int
void Delays(uint x)
{

uint i,j;
for(i=x;i0;i--)
for(j=110;j0;j--);
}
void main(void)
{
uchar led=0xFE;
while(1)
{P1=led;
led=led1;
Delays(300);
}
}

















<h4 class=\"ask\">追问





<pre class=\"replyask-text\" id=\"content-2458206\">我的程序要实现的是从左到右依次灭,其余的灯市亮的,而不是都灭啦。
回复

使用道具 举报

千问 | 2011-4-6 11:46:23 | 显示全部楼层
<pre class=\"replyask-text\" id=\"content-2458304\">这个应该就是从左到右依次灭啊
回复

使用道具 举报

千问 | 2011-4-6 11:46:23 | 显示全部楼层
<pre class=\"replyask-text\" id=\"content-2458847\">你这样程序出来的是后面的灯都灭啦,P1=1111 1110,左移一位以后变成P1=1111 1100啦,而我想要的移位以后变成P1=1111 1101
回复

使用道具 举报

千问 | 2011-4-6 11:46:23 | 显示全部楼层
<pre class=\"replyask-text\" id=\"content-2459195\">这简单,我给你改下就OK了
#includereg51.h
#define uchar unsigned char
#define uint unsigned int
void Delays(uint x)
{

uint i,j;
for(i=x;i0;i--)
for(j=110;j0;j--);
}
void main(void)
{
uchar led=0xFE;
while(1)
{P1=led;
led=led1;
led;
Delays(300);
}
}
回复

使用道具 举报

千问 | 2011-4-6 11:46:23 | 显示全部楼层
<pre class=\"replyask-text\" id=\"content-2457368\">能在源程序的基础上改吗?
回复

使用道具 举报

您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

主题

0

回帖

4882万

积分

论坛元老

Rank: 8Rank: 8

积分
48824836
热门排行