标题:
一串LED灯怎么做出流星划过的效果?
[打印本页]
作者:
CAPCL
时间:
2024-3-30 17:38
标题:
一串LED灯怎么做出流星划过的效果?
向各位大佬们求助:
有没有什么思路可以实现一串LED灯的流星划过的效果?
就一个LED来说,首先要实现从亮到暗,也就是呼吸灯的效果,一连串呼吸灯依次点亮再依次变暗,就可以实现流星灯,但软硬件上如何实现呢?求教。
51hei.jpg
(23.51 KB, 下载次数: 27)
下载附件
2024-3-30 21:58 上传
作者:
Hephaestus
时间:
2024-3-30 22:50
一个一个的点亮,从头到尾,至于流星尾巴的效果交给眼睛的延迟处理吧。
作者:
Y_G_G
时间:
2024-3-30 23:17
流水灯,第一个100%亮度,第二个90%亮度,第三个80%亮度.........以此类推
所以,就不能直接用左移或者右移来流水了
你可以网上找一下流星代码,参考一下就知道了
作者:
wulin
时间:
2024-3-31 09:02
硬件上与流水灯没有不同,软件上就是PWM调光。
#include<reg52.h>
#include<intrins.h>
#define uchar unsigned char
#define uint unsigned int
sbit D0 = P1^0;
sbit D1 = P1^1;
sbit D2 = P1^2;
sbit D3 = P1^3;
sbit D4 = P1^4;
sbit D5 = P1^5;
sbit D6 = P1^6;
sbit D7 = P1^7;
uchar PWM0 = 15;
uchar PWM1 = 17;
uchar PWM2 = 19;
uchar PWM3 = 21;
uchar PWM4 = 23;
uchar PWM5 = 25;
uchar PWM6 = 27;
uchar PWM7 = 29;
uchar count=0;
uchar num=0;
void main()
{
TMOD=0x01;
TH0=(65536-500)/256;
TL0=(65536-500)%256;
EA=1;
ET0=1;
TR0=1;
while(1)
{
if(num==50)
{
num=0;
PWM7++;PWM6++;PWM5++;PWM4++;
PWM3++;PWM2++;PWM1++;PWM0++;
if(PWM7==30) PWM7=0;
if(PWM6==30) PWM6=0;
if(PWM5==30) PWM5=0;
if(PWM4==30) PWM4=0;
if(PWM3==30) PWM3=0;
if(PWM2==30) PWM2=0;
if(PWM1==30) PWM1=0;
if(PWM0==30) PWM0=0;
}
}
}
void Timer0(void) interrupt 1
{
TH0=(65536-500)/256;
TL0=(65536-500)%256;
count++;
num++;
if(count >= 15) count = 0;
if(count >= PWM7) D0 = 0; else D0 = 1;
if(count >= PWM6) D1 = 0; else D1 = 1;
if(count >= PWM5) D2 = 0; else D2 = 1;
if(count >= PWM4) D3 = 0; else D3 = 1;
if(count >= PWM3) D4 = 0; else D4 = 1;
if(count >= PWM2) D5 = 0; else D5 = 1;
if(count >= PWM1) D6 = 0; else D6 = 1;
if(count >= PWM0) D7 = 0; else D7 = 1;
}
复制代码
作者:
samsung9454
时间:
2024-3-31 10:38
幻彩灯带(WS2812等)你值得拥有。
欢迎光临 (http://www.51hei.com/bbs/)
Powered by Discuz! X3.1