Hi all, some of you may have seen this in the IRC chat, my issue is I want to illuminate balloons using RGB leds to create pattern, here are a few videos to show my concept...
This is what I want the balloons to do...
As you can see there are a lot of balloons to control, about 350 minimum but we want as many as we can...
The issue I am having is we want it to fade through colours and I can't really get any further than fading 3-5 RGB LEDs (which obviously translates to 9-15 PWM channels.
TLC5940 Library - Google Code Archive - Long-term storage for Google Code Project Hosting.
This is my code which makes random choices but it could be modified to do other things.
Can anyone help me solve the scalability issue?
#include "Tlc5940.h"
#include "tlc_fades.h"
int red = 2048;
int green = 4095;
int blue = 3893;
byte current_r[5], current_g[5], current_b[5];
TLC_CHANNEL_TYPE channel = 1;
void setup() {
Tlc.init();
Serial.begin(9600);
}
void loop() {
if (!tlc_updateFades()) {
fadeRGB(channel, byte(random(0, 255)), byte(random(0, 255)), byte(random(0, 255)), 0, 500);
channel++;
if (channel >= 3) channel = 1;
}
}
boolean fadeRGB(TLC_CHANNEL_TYPE channel, byte r, byte g, byte b, uint32_t wait, uint32_t duration) {
if (!rgbIsFading(channel)) {
TLC_CHANNEL_TYPE redChannel = (channel * 3) - 3;
TLC_CHANNEL_TYPE greenChannel = (channel * 3) - 2;
TLC_CHANNEL_TYPE blueChannel = (channel * 3 ) - 1;
tlc_removeFades(redChannel);
tlc_removeFades(greenChannel);
tlc_removeFades(blueChannel);
}
uint32_t startFade = millis() + wait;
uint32_t endFade = millis() + wait + duration;
int fromRed = map(int(current_r[channel-1]), 0, 255, 0, red);
int fromGreen = map(int(current_g[channel-1]), 0, 255, 0, green);
int fromBlue = map(int(current_b[channel-1]), 0, 255, 0, blue);
int toRed = map(int(r), 0, int(0xFF), 0, red);
int toGreen = map(int(g), 0, int(0xFF), 0, green);
int toBlue = map(int(b), 0, int(0xFF), 0, blue);
TLC_CHANNEL_TYPE redChannel = (channel * 3) - 3;
TLC_CHANNEL_TYPE greenChannel = (channel * 3) - 2;
TLC_CHANNEL_TYPE blueChannel = (channel * 3 ) - 1;
tlc_addFade(redChannel, fromRed, toRed, startFade, endFade);
tlc_addFade(greenChannel, fromGreen, toGreen, startFade, endFade);
tlc_addFade(blueChannel, fromBlue, toBlue, startFade, endFade);
current_r[channel-1] = r;
current_g[channel-1] = g;
current_b[channel-1] = b;
}
boolean rgbIsFading(TLC_CHANNEL_TYPE channel) {
if (tlc_isFading((channel * 3) - 3) && tlc_isFading((channel * 3) - 2) && tlc_isFading((channel * 3 ) - 1)) {
return true;
} else {
return false;
}
}
