应广单片机吧 关注:141贴子:454
  • 0回复贴,共1

PMS150G*WS2812B流水灯

只看楼主收藏回复

/*******************774145445**********************/
/*************PMS150G***WS2812B流水灯**************/
/******************20200802************************/
/**************************************************/
#include"extern.h"
chuanbitpa.0;//串行线
//k1bitpa.1;
voidfuwei();//复位
voidyi();//1码
voidling();//0码
voidyanshi();//延时
voidxianshi();//显示
voidxianshi0();
voidxianshi1();
voidanjian();//按键
bytehong;//红
bytelv;//绿
bytelan;//蓝
byteliangdu=0x01;//亮度
bytea1=0x01;
voidFPPA0 (void)
{
.ADJUST_ICSYSCLK=IHRC/4//4M
byteb1,b2;
$chuanout,low;//设置为输出,低
while (1)
{
a1=0b1000_0000;
b1=8;
while(b1)
{
b1--;
xianshi();
a1>>=1;//右移一位
yanshi();
}
liangdu+=20;
a1=0b0000_0001;
b1=8;
while(b1)
{
b1--;
xianshi();
a1<<=1;//左移一位
yanshi();
}
liangdu+=20;
}
}
/**************************************************/
voidfuwei()
{
//chuan=1;
//nop;
chuan=0;
.delay1500;//1200//2400
//chuan=1;
}
/**************************************************/
voidyi()
{
chuan=0;
nop;
chuan=1;
nop;
nop;
nop;
nop;
chuan=0;
nop;
}
/**************************************************/
voidling()
{
chuan=0;
nop;
chuan=1;
//nop;
chuan=0;
nop;
nop;
nop;
nop;
}
/**************************************************/
voidxianshi()
{
hong=liangdu;
lv=liangdu;
lan=liangdu;
fuwei();
if(a1.7){xianshi1();}else{xianshi0();}
if(a1.6){xianshi1();}else{xianshi0();}
if(a1.5){xianshi1();}else{xianshi0();}
if(a1.4){xianshi1();}else{xianshi0();}
if(a1.3){xianshi1();}else{xianshi0();}
if(a1.2){xianshi1();}else{xianshi0();}
if(a1.1){xianshi1();}else{xianshi0();}
if(a1.0){xianshi1();}else{xianshi0();}
}
/**************************************************/
voidxianshi1()
{
//高位先发,按照 GRB 的顺序发送数据
if(lv.7){yi();}else{ling();}
if(lv.6){yi();}else{ling();}
if(lv.5){yi();}else{ling();}
if(lv.4){yi();}else{ling();}
if(lv.3){yi();}else{ling();}
if(lv.2){yi();}else{ling();}
if(lv.1){yi();}else{ling();}
if(lv.0){yi();}else{ling();}
if(hong.7){yi();}else{ling();}
if(hong.6){yi();}else{ling();}
if(hong.5){yi();}else{ling();}
if(hong.4){yi();}else{ling();}
if(hong.3){yi();}else{ling();}
if(hong.2){yi();}else{ling();}
if(hong.1){yi();}else{ling();}
if(hong.0){yi();}else{ling();}
if(lan.7){yi();}else{ling();}
if(lan.6){yi();}else{ling();}
if(lan.5){yi();}else{ling();}
if(lan.4){yi();}else{ling();}
if(lan.3){yi();}else{ling();}
if(lan.2){yi();}else{ling();}
if(lan.1){yi();}else{ling();}
if(lan.0){yi();}else{ling();}
}
/**************************************************/
voidxianshi0()
{
bytec1;
c1=24;
while(c1)//发送24次0
{
c1--;
ling();
}
}
/**************************************************/
/**************************************************/
voidyanshi()
{
.delay2000000;
}
/**************************************************/


IP属地:北京1楼2020-08-08 15:55回复