标题:
关于流星灯只能运行一次的程序如何修改
[打印本页]
作者:
heicad
时间:
2016-3-11 22:16
标题:
关于流星灯只能运行一次的程序如何修改
程序如下,好像这程序只能运行一次,也好像是运行一次要好久才会有下一次,求大神修改
#include <reg52.h>
#include <intrins.h>
#define D1 P1
uchar code PWM[8]={0,1,2,4,8,16,32,64};
uchar code sudu[16]={1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16};
uint u,j,k,count,temp;
void main()
{
int i;
D1=0xFF;
while(1)
{
for(u=0;u<16;i++)
{
for(count=0;count<=sudu[2]; count++)
{
temp=0x00;
for(j=0;j<64; j++)
{
for(k=0;k<8;k++)
{
if(PWM[k]==j)
{
temp |= (1 << k);
}
}
if(i<=7)
{
D1 = ~((~temp) >> (7-i));
}
else
{
D1 = ~((~temp) << (i-7));
}
}
}
}
}
}
作者:
heicad
时间:
2016-3-11 22:16
不知道你说的流星灯什么效果,不过上边这个函数,什么也没哟,我仿真了一下
作者:
heicad
时间:
2016-3-11 22:16
heicad 发表于 2016-3-11 22:16
不知道你说的流星灯什么效果,不过上边这个函数,什么也没哟,我仿真了一下
#include <reg51.h>
#include <intrins.h>
#define D1 P1
char code PWM[8]={0,1,2,4,8,16,32,64};
char code sudu[16]={1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16};
int u,j,k,count,temp;
void main()
{
int i;
D1=0xFF;
while(1)
{
for(u=0;u<16;i++)
{
for(count=0;count<=sudu[2]; count++)
{
temp=0x00;
for(j=0;j<64; j++)
{
for(k=0;k<8;k++)
{
if(PWM[k]==j)
{
temp |= (1 << k);
}
}
if(i<=7)
{
D1 = ~((~temp) >> (7-i));
}
else
{
D1 = ~((~temp) << (i-7));
}
}
}
}
}
}
弄错了,是这个,上面那个uchar没改
作者:
heicad
时间:
2016-3-11 22:16
不是这的问题,我之前仿真改过这个位置了,不改也不能编译呀
作者:
iamtian
时间:
2018-5-31 20:13
共8个灯亮四个灯的怎么改
作者:
向日葵男人
时间:
2018-8-13 22:31
用char类型的试试
欢迎光临 (http://www.51hei.com/bbs/)
Powered by Discuz! X3.1