|
发表于 2015-7-6 13:26:10
|
显示全部楼层
892720757 发表于 2015-4-4 15:25
大神能发给我一份驱动程序吗,小弟刚刚入门,自己写不出来。我邮箱。。感激不尽
#include "Tlc5940.h"
void setup()
{
Tlc.init();
#define mils 10
#define STEP 1
#define red
}
void loop()
{
//There are 4095 steps from off 0 to max on 4095.
//Reference Color defined as RC
//The color you would like to be the dominant color will be the reference color
//Secondary dim colors to be combined will be referenced to RC
int r = 0;
int g = 0;
int b = 0;
for(int RC=0;RC<4095;RC=RC+STEP){
r = RC;
///////////////////RED LEDs
Tlc.set(0, r);
Tlc.set(3, r);
Tlc.set(6, r);
Tlc.set(9, r);
Tlc.set(12, r);
Tlc.set(15, r);
Tlc.set(18, r);
Tlc.set(21, r);
///////////////////Green LEDS
Tlc.set(1, g);
Tlc.set(4, g);
Tlc.set(7, g);
Tlc.set(10, g);
Tlc.set(13, g);
Tlc.set(16, g);
Tlc.set(19, g);
Tlc.set(22, g);
///////////////////Blue LEDS
Tlc.set(2, b);
Tlc.set(5, b);
Tlc.set(8, b);
Tlc.set(11, b);
Tlc.set(14, b);
Tlc.set(17, b);
Tlc.set(20, b);
Tlc.set(23, b);
Tlc.update();
delay(mils);
}
for(int RC=4095;RC>0;RC=RC-STEP){
r = RC;
///////////////////RED LEDs
Tlc.set(0, r);
Tlc.set(3, r);
Tlc.set(6, r);
Tlc.set(9, r);
Tlc.set(12, r);
Tlc.set(15, r);
Tlc.set(18, r);
Tlc.set(21, r);
///////////////////Green LEDS
Tlc.set(1, g);
Tlc.set(4, g);
Tlc.set(7, g);
Tlc.set(10, g);
Tlc.set(13, g);
Tlc.set(16, g);
Tlc.set(19, g);
Tlc.set(22, g);
///////////////////Blue LEDS
Tlc.set(2, b);
Tlc.set(5, b);
Tlc.set(8, b);
Tlc.set(11, b);
Tlc.set(14, b);
Tlc.set(17, b);
Tlc.set(20, b);
Tlc.set(23, b);
Tlc.update();
delay(mils);
}
} |
|