Adafruit_Neopixel fill() Function Help

Post here about your Arduino projects, get help - for Adafruit customers!

Moderators: adafruit_support_bill, adafruit

Please be positive and constructive with your questions and comments.
Locked
User avatar
savall21
 
Posts: 21
Joined: Sun Jul 19, 2020 8:25 pm

Adafruit_Neopixel fill() Function Help

Post by savall21 »

I'm trying to use the Adafruit_Neopixel fill() function to light two separate segments of the Neopixel strip. It looks like I'm doing something wrong with the color input. The second fill command is working but not the first. Can someone tell me the correct syntax?

Code: Select all

#include <Adafruit_NeoPixel.h>

#define LED_COUNT 129
#define LED_PIN A4

Adafruit_NeoPixel strip(LED_COUNT, LED_PIN, NEO_GRB + NEO_KHZ800);
void setup() {
  strip.begin();
}

void loop() {
  strip.fill((255, 0, 0), 1, 10);
  strip.fill((0, 0, 255), 20);
  strip.show();   // Send the updated pixel colors to the hardware.
}

User avatar
adafruit_support_bill
 
Posts: 88093
Joined: Sat Feb 07, 2009 10:11 am

Re: Adafruit_Neopixel fill() Function Help

Post by adafruit_support_bill »

It is not clear how many pixels you want to fill in your second call. Replace 'n' with the number of pixels to fill.

Code: Select all

  strip.fill(strip.color(255, 0, 0), 1, 10); // fill 10 pixels with RED - starting at pixel 1.
  strip.fill(strip.color(0, 0, 255), 20, n);  // fill 'n' pixels with with BLUE - starting at pixel 20

User avatar
savall21
 
Posts: 21
Joined: Sun Jul 19, 2020 8:25 pm

Re: Adafruit_Neopixel fill() Function Help

Post by savall21 »

The Adafruit NeoPixel Überguide states that if you omit the count argument it shill fill from listed input to the last. So I'm trying to go from 20 to the last pixel.

https://learn.adafruit.com/adafruit-neo ... ibrary-use

"If called without a count argument (only color and first), this will from first to the end of the strip."

Do you know what syntax is for inputing the color?

User avatar
adafruit_support_bill
 
Posts: 88093
Joined: Sat Feb 07, 2009 10:11 am

Re: Adafruit_Neopixel fill() Function Help

Post by adafruit_support_bill »

The omitted argument does default to zero as you can see in the header file:
https://github.com/adafruit/Adafruit_Ne ... NeoPixel.h

Code: Select all

  void fill(uint32_t c = 0, uint16_t first = 0, uint16_t count = 0);
But you are correct, the code interprets a 0 as 'fill to the end of the strip'.
Do you know what syntax is for inputing the color?
See the code from my previous post.

Locked
Please be positive and constructive with your questions and comments.

Return to “Arduino”