FastLED Example rainbow works but setting individual pixels does not

Hello,

I have a 520 pixel led display - WS2812B - controlled by a teensy 3.2 + octows281 adapter. I have successfully programmed it with the Octo library as well as the FastLED library but I can’t get individual pixel programming to work. When I run the fill_rainbow function (commented out in the code below) it works perfectly. However, when I try to program the individual pixels I get garbage results where ~1/10 of the pixels are filled with green.

Could someone please help me figure out what is up?

Thank you!

#include <FastLED.h>

#define LED_PIN 2
#define NUM_LEDS 520
#define BRIGHTNESS 120
#define LED_TYPE WS2812B
#define COLOR_ORDER GRB
#define UPDATES_PER_SECOND 100

CRGB leds[NUM_LEDS];
uint8_t gHue = 100; // rotating “base color” used by many of the patterns

void setup() {
delay( 3000 ); // power-up safety delay
FastLED.addLeds<LED_TYPE, LED_PIN, COLOR_ORDER>(leds, NUM_LEDS).setCorrection( TypicalLEDStrip );
FastLED.setBrightness( BRIGHTNESS );
}

void loop() {
for (int i=0; i<NUM_LEDS; i++){
leds[ “i” ] = CRGB(0,255,0); //<- does not work, quotes bc the array symbol is getting removed when I post this for some reason
}

//fill_rainbow( leds, NUM_LEDS, gHue, 7); ← works great
//EVERY_N_MILLISECONDS( 1 ) { gHue++; } // slowly cycle the “base color” through the rainbow
FastLED.show();
FastLED.delay(1000 / UPDATES_PER_SECOND);
}

Please read “Read this before posting a programming question” at the top of the forum.

Post your schematic in CAD or a picture of a hand drawn circuit in jpg or png- (not a pretty Fritzing drawing).

Try a 220-ohm series resistor on the data line. A 1,000 uF capacitor on the +5V line might help also.
Here is a video from Gadget Reboot that demonstrates why the series resistor helps false addressing. (You can skip ahead to 4:35).

leds[ “i” ] = CRGB(0,255,0); //<- does not work, quotes bc the array symbol is getting removed when I post this for some reason

The reason is that the forum software interpreters that combination of symbols into an instruction to show all following text in italics.

This is the reason we ask all users to post code in code tags, the </> symbol in the top left corner will bring these up to post your code between. Alternative use the “Copy for Forum” in the IDE and that will automatically include them.

The reason it will not work is because you do not set individual LEDs like this, you should use:-

leds[i].setRGB(0,255,0);

See Pixel reference · FastLED/FastLED Wiki · GitHub for the different ways you can set an individual pixel.

Grumpy_Mike:
The reason it will not work is because you do not set individual LEDs like this, you should use:-

leds[i].setRGB(0,255,0);

See Pixel reference · FastLED/FastLED Wiki · GitHub for the different ways you can set an individual pixel.

I’m not really seeing where his method of setting the pixel is wrong, from the page you linked, the various methods include:

//Example 2: set color from red, green, and blue components all at once
  leds[i] = CRGB( 50, 100, 150);

Not sure what his problem could be, but I’m not familiar with the OCTOWS281 adapter or its library. The adapter does appear to have 100 ohm resistors in series with the data lines, although that is a bit lower than most recommendations I’ve seen.

Would be interesting to know if the LEDs that properly light as GREEN are all contiguous, or scattered along the LED strip, and whether or not the remaining LEDs are completely off, or a different color.

hi, this sounds like a grounding issue to me. What happens you set leds = crgb (0, 0, 0); ???
are you sure the ground of your power supply to the leds is connected to the teensy?

Qdeathstar:
hi, this sounds like a grounding issue to me. What happens you set leds = crgb (0, 0, 0); ???
are you sure the ground of your power supply to the leds is connected to the teensy?
[/quote]
How about using nobbc tags :slight_smile:
[nobbc]leds[i] = crgb (0, 0, 0);[/nobbc] gives
* *leds[i] = crgb (0, 0, 0);* *

sterretje:
How about using nobbc tags :slight_smile:

Why? :astonished:

So I don't have to read a post that's about 50% in italics :smiley:

i like italics tho :frowning:

sterretje:
So I don't have to read a post that's about 50% in italics :smiley:

What a strange comment! :astonished:

You post code in "code" tags and it is correctly formatted and presented in a practical fashion in a scrolling window - which can be enlarged at your convenience.

Why would you want to suggest a more difficult and less functional method just to confuse a newbie? :cold_sweat:

Because it's inline. Did you note how little space it takes :smiley: