I was wondering if it is possible to drive two different types of RGB LED from the same board using FastLED? Specifically, I would like to drive Neopixels from a Kickstarter-funded, High Powered LED built onto a compact ATMEGA32u4 footprint called the Visualight (https://github.com/lpercifield/visualight/wiki).
I’ll add a more detailed post to the “Show off your work” thread about the project itself but basically, I’m using a Neopixel Strip and the Visualight to build a baby-room star-light projector and it works amazingly! The only problem is I’m actually using two different projectors- one with the Visualight with an Arduino Uno powering a stepper motor that rotates the pin hole covering, and another housing a Neopixel strip attached to an Adafruit Pro Trinket. It would be perfect if I could control all the light from the Visualight itself and use the Pro Trinket for the stepper.
You can totally drive different LED types at the same time from the same board with FastLED!
Just use “FastLED.addLeds” twice, once for each strip of LEDs, telling it what pin number and LED type is involved, and that’s pretty much it-- it just works.
Give it a try and let us know what you find!
Is there an option for controlling a generic RGB-LED? The embedded Visualight bulb is controlled as if it were a generic four pin through-hole RGB LED. For example the code I am using now simply modifies the default “fade” sketch-
/*
Fade
This example shows how to fade an LED on pin 9
using the analogWrite() function.
This example code is in the public domain.
*/
int led = 10; // the pin that the LED is attached to
int brightness = 0; // how bright the LED is
int fadeAmount = 5; // how many points to fade the LED by
// the setup routine runs once when you press reset:
void setup() {
// declare pin 9 to be an output:
pinMode(led, OUTPUT);
}
// the loop routine runs over and over again forever:
void loop() {
// set the brightness of pin 9:
analogWrite(led, brightness);
// change the brightness for next time through the loop:
brightness = brightness + fadeAmount;
// reverse the direction of the fading at the ends of the fade:
if (brightness == 0 || brightness == 255) {
fadeAmount = -fadeAmount ;
}
// wait for 30 milliseconds to see the dimming effect
delay(60);
}
Yep. Check out the AnalogOutput example:
Awesome! I’m very close! The AnalogOutput example works with the Visualight almost as is, if I eliminate the red and green pins and assign the BLUEPIN with 10, the default output on Visualight. However, I can’t quite figure out how to modify this example to merge into the existing sketch I have for the Neopixels using the addLeds method. It almost looked like it would work through simple copy and paste method but I got tripped up by void setup and void loop being in reverse to the way I’m used to doing it.
So If in setup I use the AddLeds method for the Neopixels like so-
FastLED.addLeds<WS2812, 3, RGB>(leds, 33);
What would that look like for the AnalogOutput?
FastLED.addLeds<AnalogWrite, 10, RGB>(leds,1)?
(Note: Generally speaking I keep getting errors when I set the LED Type as NEOPIXEL but it works perfectly as WS2812…)
No “addLeds” is needed at all for the analog RGB – just for the addressable pixel strips.
As for NEOPIXEL, when you specify NEOPIXEL, you should not also specify the color order. “NEOPIXEL” implies “GRB”. WS2811/WS2812/WS2812B do not imply a color order, and thus you have to specify one.
Oh so close! I can get it to compile with almost all the pieces but void loop from analog output-
void loop()
{
static uint8_t hue;
hue = hue + 1;
// Use FastLED automatic HSV->RGB conversion
showAnalogRGB( CHSV( hue, 255, 255) );
delay(20);
}
ALTHOUGH… It just occurred to me that this whole time my Neopixel sketch was based on YOUR Holiday Twinkle Lights Code!! (Great work BTW!!!)
It may just be some easy fundamental Arduino stuff that I’m rusty on, but I can’t figure out where to fit in the analog functions in the void loop… since it has all those chooseColorPalette’s etc… that make it so easy to work with in the first place…
Can you put the compile output / error either here (if short) or into a pastebin (if long) ?
That’s strange, I replied to your request hours ago but it must not have posted! Sorry about the delay! In any case, the Error Output was a run of the mill- “OceanVisulaight.ino:73:1: error: expected unqualified-id before ‘{’ token
Error compiling”
But I did set up a pastebin for the sketch if you want to take a look.http://pastebin.com/6ERR6kab Once I figure it out I’ll create a proper gh-repo for the sketches, Fritzing diagrams and maybe even stl files if I can design a decent print.
Try deleting lines 73-77. Looks like there’s a stray
}
{
in the middle.
Great! It compiled! Unfortunately, it looks like one of my power supplies might have fried my Neopixel strip… So I might have to wait till a new order comes in to view the results…
Success!!! I’ll post pics of the new build in a bit. Unfortunately, the full effect is difficult to capture on camera but its better than I imagined!!! Thanks Everyone!
The first two pics on the photo album show the most recent build. I’ll update the Fritzing diagram to reflect the changes as well.




