標(biāo)題:
WS2811燈光系統(tǒng)單片機(jī)程序 22路全彩控制器
[打印本頁(yè)]
作者:
15918766121
時(shí)間:
2016-7-1 12:07
標(biāo)題:
WS2811燈光系統(tǒng)單片機(jī)程序 22路全彩控制器
WS2811燈光程序,單片機(jī)22路全彩控制器.
1、從左往右掃
2、從右往左掃
3、從中間向兩邊掃
4、從兩邊向中間掃
單片機(jī)源程序如下:
#include "includes.h"
//T_POINT idata szPoint[20];
#if 0
DelayN10ms(100);
pt.r=10;pt.g=0,pt.b=0;
memcpy(&szPoint[0],&pt,sizeof(T_POINT));
pt.r=0;pt.g=10,pt.b=0;
memcpy(&szPoint[1],&pt,sizeof(T_POINT));
pt.r=0;pt.g=0,pt.b=10;
memcpy(&szPoint[2],&pt,sizeof(T_POINT));
WS2811_Setout(&szPoint,3);
#endif
T_POINT code Design2[]=
{
#if 1
{255,0,42},
{255,0,78},
{255,0,184},
{248,0,255},
{177,0,255},
{71,0,255},
{0,42,255},
{0,113,255},
{0,184,255},
{0,220,255},
{0,255,255},
{0,255,213},
{0,255,142},
{78,255,71},
{149,255,0},
{220,255,0},
{255,213,0},
{255,177,0},
{255,71,0},
{255,0,0},
#else
{10,0,0},
{0,10,0},
{0,0,10},
{10,0,0},
{0,10,0},
{0,0,10},
{10,0,0},
{0,10,0},
{0,0,10},
{10,0,0},
{0,10,0},
{0,0,10},
{10,0,0},
{0,10,0},
{0,0,10},
{10,0,0},
{0,10,0},
{0,0,10},
{10,0,0},
{0,10,0},
#endif
};
T_POINT code Design[]=
{
{255,0,0},
{255,0,10},
{255,0,20},
{255,0,30},
{255,0,42},
{255,0,50},
{255,0,58},
{255,0,66},
{255,0,72},
{255,0,78},
{255,0,90},
{255,0,110},
{255,0,130},
{255,0,150},
{255,0,184},
{245,0,200},
{230,0,215},
{222,0,230},
{200,0,238},
{190,0,245},
{177,0,255},
{160,0,255},
{140,0,255},
{130,0,255},
{120,0,255},
{110,0,255},
{100,0,255},
{95,0,255},
{85,0,255},
{71,0,255},
{56,8,255},
{40,16,255},
{30,24,255},
{20,32,255},
{10,36,255},
{0,42,255},
{0,57,255},
{0,72,255},
{0,87,255},
{0,95,255},
{0,98,255},
{0,102,255},
{0,113,255},
{0,184,255},
{0,190,255},
{0,200,255},
{0,210,255},
{0,220,255},
{0,230,255},
{0,240,255},
{0,255,255},
{0,255,245},
{0,255,235},
{0,255,225},
{0,255,215},
{0,255,200},
{0,255,190},
{0,255,180},
{0,255,170},
{10,255,160},
{20,255,150},
{30,255,140},
{40,255,130},
{50,255,120},
{60,255,110},
{70,255,100},
{78,255,90},
{90,255,80},
{95,255,71},
{100,255,60},
{105,255,50},
{110,255,40},
{120,255,30},
{130,255,20},
{140,255,10},
{149,255,0},
{160,255,0},
{170,255,0},
{180,255,0},
{190,255,0},
{200,255,0},
{210,255,0},
{220,255,0},
{230,245,0},
{240,235,0},
{245,225,0},
{255,213,0},
{255,208,0},
{255,200,0},
{255,190,0},
{255,180,0},
{255,177,0},
{255,170,0},
{255,160,0},
{255,150,0},
{255,140,0},
{255,130,0},
{255,120,0},
{255,110,0},
{255,100,0},
{255,90,0},
{255,80,0},
{255,75,0},
{255,60,0},
{255,50,0},
{255,40,0},
{255,30,0},
{255,20,0},
{255,10,0},
{255,0,0},
};
void WS2811_Setout2(int index)
{//748
int k=10;
uchar cnt=0;
while(1)
{
WS2811_SendByte(Design[index].r);
WS2811_SendByte(Design[index].b);
WS2811_SendByte(Design[index].g);
index++;
if(index==110)
{
index=0;
}
if(++cnt==110)
{
break;
}
}
IO_DIN=1;
IO_DIN=0;
while(k--)
{
_nop_();
}
}
void WS2811_Setout4(int index)
{//748
int k=10;
uchar cnt=0;
while(1)
{
WS2811_SendByte(Design[index].r);
WS2811_SendByte(Design[index].b);
WS2811_SendByte(Design[index].g);
index+=2;
if(index>=110)
{
index=0;
}
if(++cnt==55)
{
break;
}
}
cnt=0;
while(1)
{
WS2811_SendByte(Design[index].r);
WS2811_SendByte(Design[index].b);
WS2811_SendByte(Design[index].g);
index-=2;
if(index<0)
{
index=109;
}
if(++cnt==55)
{
break;
}
}
IO_DIN=1;
IO_DIN=0;
while(k--)
{
_nop_();
}
}
void WS2811_Setout3(int index)
{//748
int k=10;
uchar cnt=0,n;
// while(1)
{
//----------------
for(n=0;n<4;n++)
{
WS2811_SendByte(Design2[index].r);
WS2811_SendByte(Design2[index].b);
WS2811_SendByte(Design2[index].g);
}
if(++index==20)
{
index=0;
}
//----------------
for(n=0;n<4;n++)
{
WS2811_SendByte(Design2[index].r);
WS2811_SendByte(Design2[index].b);
WS2811_SendByte(Design2[index].g);
}
if(++index==20)
{
index=0;
}
//----------------
for(n=0;n<3;n++)
{
WS2811_SendByte(Design2[index].r);
WS2811_SendByte(Design2[index].b);
WS2811_SendByte(Design2[index].g);
}
if(++index==20)
{
index=0;
}
//----------------
for(n=0;n<3;n++)
{
WS2811_SendByte(Design2[index].r);
WS2811_SendByte(Design2[index].b);
WS2811_SendByte(Design2[index].g);
}
if(++index==20)
{
index=0;
}
//----------------
for(n=0;n<3;n++)
{
WS2811_SendByte(Design2[index].r);
WS2811_SendByte(Design2[index].b);
WS2811_SendByte(Design2[index].g);
}
if(++index==20)
{
index=0;
}
//----------------
for(n=0;n<2;n++)
{
WS2811_SendByte(Design2[index].r);
WS2811_SendByte(Design2[index].b);
WS2811_SendByte(Design2[index].g);
}
if(++index==20)
{
index=0;
}
//----------------
for(n=0;n<2;n++)
{
WS2811_SendByte(Design2[index].r);
WS2811_SendByte(Design2[index].b);
WS2811_SendByte(Design2[index].g);
}
if(++index==20)
{
index=0;
}
//----------------
for(n=0;n<2;n++)
{
WS2811_SendByte(Design2[index].r);
WS2811_SendByte(Design2[index].b);
WS2811_SendByte(Design2[index].g);
}
if(++index==20)
{
index=0;
}
//----------------
for(n=0;n<2;n++)
{
WS2811_SendByte(Design2[index].r);
WS2811_SendByte(Design2[index].b);
WS2811_SendByte(Design2[index].g);
}
if(++index==20)
{
index=0;
}
//----------------
for(n=0;n<2;n++)
{
WS2811_SendByte(Design2[index].r);
WS2811_SendByte(Design2[index].b);
WS2811_SendByte(Design2[index].g);
}
if(++index==20)
{
index=0;
}
//----------------
for(n=0;n<2;n++)
{
WS2811_SendByte(Design2[index].r);
WS2811_SendByte(Design2[index].b);
WS2811_SendByte(Design2[index].g);
}
if(++index==20)
{
index=0;
}
//----------------
for(n=0;n<2;n++)
{
WS2811_SendByte(Design2[index].r);
WS2811_SendByte(Design2[index].b);
WS2811_SendByte(Design2[index].g);
}
if(++index==20)
{
index=0;
}
//----------------
for(n=0;n<5;n++)
{
WS2811_SendByte(Design2[index].r);
WS2811_SendByte(Design2[index].b);
WS2811_SendByte(Design2[index].g);
}
if(++index==20)
{
index=0;
}
//----------------
for(n=0;n<8;n++)
{
WS2811_SendByte(Design2[index].r);
WS2811_SendByte(Design2[index].b);
WS2811_SendByte(Design2[index].g);
}
if(++index==20)
{
index=0;
}
//----------------
for(n=0;n<7;n++)
{
WS2811_SendByte(Design2[index].r);
WS2811_SendByte(Design2[index].b);
WS2811_SendByte(Design2[index].g);
}
if(++index==20)
{
index=0;
}
//----------------
for(n=0;n<7;n++)
{
WS2811_SendByte(Design2[index].r);
WS2811_SendByte(Design2[index].b);
WS2811_SendByte(Design2[index].g);
}
if(++index==20)
{
index=0;
}
//----------------
for(n=0;n<5;n++)
{
WS2811_SendByte(Design2[index].r);
WS2811_SendByte(Design2[index].b);
WS2811_SendByte(Design2[index].g);
}
if(++index==20)
{
index=0;
}
//----------------
for(n=0;n<4;n++)
{
WS2811_SendByte(Design2[index].r);
WS2811_SendByte(Design2[index].b);
WS2811_SendByte(Design2[index].g);
}
if(++index==20)
{
index=0;
}
//----------------
for(n=0;n<3;n++)
{
WS2811_SendByte(Design2[index].r);
WS2811_SendByte(Design2[index].b);
WS2811_SendByte(Design2[index].g);
}
if(++index==20)
{
index=0;
}
//----------------
//for(n=0;n<1;n++)
{
WS2811_SendByte(Design2[index].r);
WS2811_SendByte(Design2[index].b);
WS2811_SendByte(Design2[index].g);
}
}
IO_DIN=1;
IO_DIN=0;
while(k--)
{
_nop_();
}
}
ucharc SPEED1[]={10,8, 6, 4,2,0};
ucharc SPEED[]= {20,15,10,6,2,0};
void main(void)
{
int ind=19;
uchar cnt;
Init_Data(); // 初始化各種端口和數(shù)據(jù)
while(1)
{
#if 1
/*
1、從左往右掃
2、從右往左掃
3、從中間向兩邊掃
4、從兩邊向中間掃
*/
for(cnt=0;cnt<3;cnt++)
{
for(ind=0;ind<110;ind++)
{
WS2811_Setout2(ind);
DelayN10ms(SPEED1[gSpeed]);
}
}
for(cnt=0;cnt<3;cnt++)
{
for(ind=109;ind>=0;ind--)
{
WS2811_Setout2(ind);
DelayN10ms(SPEED1[gSpeed]);
}
}
//33333333333
for(cnt=0;cnt<3;cnt++)
{ //3.從55-110-1-54掃描
for(ind=55;ind<110;ind++)
{
WS2811_Setout2(ind);
DelayN10ms(SPEED1[gSpeed]);
}
for(ind=0;ind<55;ind++)
{
WS2811_Setout2(ind);
DelayN10ms(SPEED1[gSpeed]);
}
}
//444444444444444
for(cnt=0;cnt<3;cnt++)
{ //4.從54-1-110-55掃描
for(ind=54;ind>=0;ind--)
{
……………………
…………限于本文篇幅 余下代碼請(qǐng)從51黑下載附件…………
復(fù)制代碼
0.png
(42.84 KB, 下載次數(shù): 115)
下載附件
2017-3-15 04:35 上傳
0.png
(60.07 KB, 下載次數(shù): 128)
下載附件
2017-3-15 04:35 上傳
源碼下載:
WS2811_LEDs.zip.7z
(37.95 KB, 下載次數(shù): 305)
2022-4-23 16:01 上傳
點(diǎn)擊文件名下載附件
下載積分: 黑幣 -5
作者:
faridzled
時(shí)間:
2017-1-4 21:22
Thanks for sharing, i like it
作者:
quest_smt
時(shí)間:
2017-5-4 22:30
剛好需要,正在學(xué)單片機(jī)呢。謝謝分享
作者:
_少年放肆的夢(mèng)
時(shí)間:
2017-5-4 23:13
謝謝分享
作者:
yokochristina
時(shí)間:
2017-6-8 15:14
謝謝樓主
作者:
zhengen
時(shí)間:
2017-6-17 12:18
交流一下好嘛
作者:
zhengen
時(shí)間:
2017-6-17 12:39
黑幣不夠,非常想下載這個(gè)資源,求通過(guò)
作者:
b2329164
時(shí)間:
2017-9-7 14:26
謝大大分享 剛好正在使用
作者:
yerdong
時(shí)間:
2017-11-23 16:50
LZ是用的,延時(shí)的方式還是PWM輸出的方式控制?
作者:
簡(jiǎn)近樹(shù)
時(shí)間:
2017-12-17 19:21
可以很強(qiáng)
作者:
mch205
時(shí)間:
2018-3-8 10:32
開(kāi)始學(xué)習(xí)了
作者:
baishifanzon
時(shí)間:
2018-4-18 13:43
好好學(xué)習(xí)一下,感謝樓主無(wú)私的分享!
作者:
101113b
時(shí)間:
2018-4-23 13:36
給力,下載看看
作者:
101113b
時(shí)間:
2018-4-23 13:38
學(xué)習(xí)一下感謝樓主無(wú)私的分享!
作者:
21cnxin
時(shí)間:
2018-6-29 14:56
學(xué)習(xí)一下感謝樓主無(wú)私的分享!
作者:
only畫地為牢
時(shí)間:
2019-7-4 20:09
正在學(xué)習(xí)這個(gè)IC的用法 贊一個(gè)!
作者:
夕日東
時(shí)間:
2020-3-29 23:27
Thanks for sharing, i like it
作者:
huihuangzeng
時(shí)間:
2023-9-18 22:59
謝謝壇主。學(xué)習(xí)了。
作者:
wkman
時(shí)間:
2023-9-19 14:00
一路多少顆燈珠?
歡迎光臨 (http://www.torrancerestoration.com/bbs/)
Powered by Discuz! X3.1