Due to high demand expect some shipping delays at this time, orders may not ship for 1-2 business days.
0

Using NEOPixel with NEO_RGB & NEO_GRB not working
Moderators: adafruit_support_bill, adafruit

Forum rules
If you're posting code, please make sure your code does not include your Adafruit IO Active Key or WiFi network credentials.
Please be positive and constructive with your questions and comments.

Using NEOPixel with NEO_RGB & NEO_GRB not working

by NM_Artist on Tue Oct 26, 2021 1:29 am

Hi, I have two types of NEOPIXELS from Adafruit. One is NEO_GRB and the other, that I just received, is NEO_RGB. Using #include <Adafruit_NeoPixel.h> I can daisy chain these on a breadboard, but Red and Green colors are switched when given the same hex code. I have attempted creating an additional object for each NEO_GRB and NEO_RGB, i.e.,

Adafruit_NeoPixel pixel_1(PIXELCOUNT, PIXELPIN_1, NEO_RGB + NEO_KHZ800); // declare object
Adafruit_NeoPixel pixel_2(PIXELCOUNT, PIXELPIN_2, NEO_GRB + NEO_KHZ800); // declare object

When I do this only the NEOPIXEL for pixel_1 lights up with the following code:

pixel_1.begin();
pixel_2.begin();
bri = 100;
pixel_1.setBrightness(bri);
pixel_2.setBrightness(bri);
pixel_1.setPixelColor(n, 0xFF0000); // Sets LED on pin 11 to Red
pixel_2.setPixelColor(1, 0xFF0000); // Sets LED on pin 12 to Red
delay(500);
pixel_1.show();
pixel_2.show();

I'm seeking advice for the best way to use two Adafruit_NeoPixel objects in the same program, or, failing that, what is a work-around might be for using both RGB and GRB Neopixels in the same program.

Thank you

NM_Artist
 
Posts: 2
Joined: Tue Oct 26, 2021 1:06 am

Re: Using NEOPixel with NEO_RGB & NEO_GRB not working

by dastels on Tue Oct 26, 2021 8:06 am

A couple questions:

What happens if you swap the order of the two begin calls?
What MCU/board are you running this on?

Dave

dastels
 
Posts: 7983
Joined: Tue Oct 20, 2015 3:22 pm

Re: Using NEOPixel with NEO_RGB & NEO_GRB not working

by NM_Artist on Tue Oct 26, 2021 10:26 am

Hi Dave,
Thanks for responding :) I'm doing this on a Teensy 3.2, but the problem was in my array addressing. When I created the second object,

"pixel_2.setPixelColor(1, 0xFF0000); // Sets LED on pin 12 to Red,"

I forgot to set the array call for the 1st pixel to 0, from 1.
After making that change it's working correctly now.

Best,
Ivan

NM_Artist
 
Posts: 2
Joined: Tue Oct 26, 2021 1:06 am

Re: Using NEOPixel with NEO_RGB & NEO_GRB not working

by dastels on Tue Oct 26, 2021 10:30 am

OK, cool.

Dave

dastels
 
Posts: 7983
Joined: Tue Oct 20, 2015 3:22 pm

Please be positive and constructive with your questions and comments.