标题: 求修改程序达到使led指示灯两两右循环 楼主小白 [打印本页]
作者: akp123 时间: 2014-11-23 10:14
标题: 求修改程序达到使led指示灯两两右循环 楼主小白
#include<reg51.h>
code unsigned charC51BOX2[3] _at_ 0x43;
void delay(void);
unsigned charRL(unsigned char c,n);
main()
{
unsigned char n; /*n是循环移位数*/
P0 = 0xFE; /*P1为11111110*/
n = 1; /*设定移位数为1,可以定义所需循环移动的位数,例如:2,3等*/
while(1)
{
P0 = RL(P0,n);
delay();
}
}
/*延时函数*/
void delay(void)
{
unsigned char i,j,k;
for(i=100;i!=0;i--)
for(j=100;j!=0;j--)
for(k=50;k!=0;k--);
}
/*循位左移位函数*/
unsigned charRL(unsigned char c,n)
{
unsigned char a,b,result;
a=c>>(8-n);
b=c<<n;
result=a|b;
return(result);
}修改上述程序,使指示灯两两右循环;
修改上述程序,使指示灯右循环间隔为0.1秒;
作者: akp123 时间: 2014-11-23 10:23
有人吗
作者: skyhanfeng 时间: 2014-11-24 11:55
改下移位符号就可以了。很简单啊
作者: 风缘 时间: 2014-11-30 19:25
/*循位左移位函数*/
unsigned charRL(unsigned char c,n)
{
unsigned char a,b,result;
a=c>>(8-n);
b=c<<n;
result=a|b;
return(result);
可以把这段程序修改成右移
欢迎光临 (http://www.51hei.com/bbs/) |
Powered by Discuz! X3.1 |