Neopixel Painter Arduino help
Moderators: adafruit_support_bill, adafruit

Please be positive and constructive with your questions and comments.

Neopixel Painter Arduino help

by unsogno on Fri Jan 04, 2019 1:50 pm


I'm using one of the examples from the Neopixel Painter library & need some help.

Currently, the code displays all colors/hues but I'd like to have it only display shades of green. Do I change the hue values so they are randomized between 100-140 for instance? Any guidance/suggestions would be helpful. Here is what I currently have:

Code: Select all | TOGGLE FULL SIZE
int led = 6;           // the PWM pin the LED is attached to

#define NUMBEROFPIXELS 24 //Number of LEDs on the strip
#define PIXELPIN 6 //Pin where pixels are connected

#include "Arduino.h"
#include <Adafruit_NeoPixel.h>
#include <NeoPixelPainter.h>

Adafruit_NeoPixel neopixels = Adafruit_NeoPixel(NUMBEROFPIXELS, PIXELPIN, NEO_GRB + NEO_KHZ800);

NeoPixelPainterCanvas pixelcanvas = NeoPixelPainterCanvas(&neopixels); //create canvas, linked to the neopixels (must be created before the brush)
NeoPixelPainterBrush pixelbrush = NeoPixelPainterBrush(&pixelcanvas); //crete brush, linked to the canvas to paint to

void setup() {
  pinMode(led, OUTPUT);

void loop() {

  while(true) //create a loop with an additional brush (is deleted automatically once the loop finishes)

    NeoPixelPainterBrush pixelbrush2 = NeoPixelPainterBrush(&pixelcanvas);

    if (pixelbrush2.isvalid() == false) Serial.println(F("brush2 allocation problem"));
    else  Serial.println(F("brush2 allocation ok"));

    static unsigned int hue = 0; //color hue to set to brush
    HSV brushcolor; //HSV color definition

      pixelbrush.setSpeed(300); //brush moving speed
      pixelbrush.setFadein(true); //brightness will fade-in if set to true

    brushcolor.h = hue / 3; //divide by 3 to slow down color fading
    brushcolor.s = 255; //full saturation
    brushcolor.v = 255; //full brightness

    pixelbrush.setColor(brushcolor); //set new color to the bursh


    pixelbrush.paint(); //paint the brush to the canvas (and update the brush, i.e. move it a little)
    pixelcanvas.transfer(); //transfer (add) the canvas to the neopixels

    break; //quit the while loop immediately (and delete the created brush)

Thank you.

Posts: 7
Joined: Wed Feb 28, 2018 5:04 pm

Please be positive and constructive with your questions and comments.