how to control individual neopixels on neopixel ring

EL Wire/Tape/Panels, LEDs, pixels and strips, LCDs and TFTs, etc products from Adafruit

Moderators: adafruit_support_bill, adafruit

Please be positive and constructive with your questions and comments.
Locked
User avatar
seidl30
 
Posts: 1
Joined: Sun Aug 02, 2015 7:17 pm

how to control individual neopixels on neopixel ring

Post by seidl30 »

Sorry I can't wrap my head around this.

I have been playing around with a gemma MO and a 12 ring neopixel and I have successfully run code from many projects that utilize more neopixels. My question is I want to be able to keep 2 neopixels a solid blue (I'm thinking the #1 and #7) and then have the surrounding neopixels fade in and out. Basically I want to give glowing eyes to a baby doll for an upcoming costume but I would like to have the forehead glow so it looks like it is pulsing under the skin. I have been able to get a single neopixel to light up but when I try to get another one to light up no such luck. I've been scouring the forums for help but I am not finding it.

I apologize for such a noob question and any help would be greatly appreciated.

thank you.

User avatar
XRAD
 
Posts: 754
Joined: Sat Nov 19, 2016 3:28 pm

Re: how to control individual neopixels on neopixel ring

Post by XRAD »

1) you could write a struct for certain groups of pins.... BluePins and FadePins

2) you could erase and rewrite all pins so fast that it would seem that some stay on and others fade in and out....

3) you could turn on certain pins ONCE in setup and then just write in loop to ONLY the other pins you want to change....

4) or easiest is to use two different hardware sets of neopixels and keep one blue all the time and fade the others

User avatar
kcl1s
 
Posts: 1512
Joined: Tue Aug 30, 2016 12:06 pm

Re: how to control individual neopixels on neopixel ring

Post by kcl1s »

In addition to XRADs suggestions I like to think of things happening to all pixels as background then reset the pixels again for the ones you want to stay the same. In the example below I fade the whole ring using the fill command but before I give the show command I reset the 1 and 7 pixels. The fill and setPixelColor commands just set a color in memory and only when you call the show command is the data sent out to the pixels.

The fade code I used uses the recently added ColorHSV command. You can read about it toward the bottom of this page https://learn.adafruit.com/adafruit-neo ... ibrary-use

Code: Select all

#include <Adafruit_NeoPixel.h>

const int LED_COUNT = 12;
const int LED_PIN = 2;
int dir = 1;
int bright = 0;
int maxBright = 20; //this can be between 0 and 255 but low numbers are better
int fadeSpeed = 100;

Adafruit_NeoPixel strip(LED_COUNT, LED_PIN, NEO_GRB + NEO_KHZ800);

void setup() {
  // put your setup code here, to run once:
  strip.begin();
  strip.show();
}

void loop() {
  // Fade your whole ring then reset the pixels you
  // want to be different before the show command
  bright = bright + dir;
  if (bright == maxBright || bright == 0) dir = dir * -1;
  uint32_t rgbcolor = strip.ColorHSV(54500, 150, bright); // flesh color
  delay(fadeSpeed);
  strip.fill(rgbcolor);
  strip.setPixelColor(1, strip.Color( 0, 0, 255));  // reset these pixels
  strip.setPixelColor(7, strip.Color( 0, 0, 255));  // reset these pixels
  strip.show();
}
If you are using Circuit Python I believe you can use a similar approach.

Fellow hobbyist
Keith

User avatar
dastels
 
Posts: 15831
Joined: Tue Oct 20, 2015 3:22 pm

Re: how to control individual neopixels on neopixel ring

Post by dastels »

The neopixel library lets you control the pixels individually. As kcl1s shows, you can use fill for set all the pixels in a strip/ring, and setPixelColor to set individuals ones. This is IMO the biggest win of neopixels and the libraries: using a single pin, but controlling each pixel individually. The trade off is that each call to show takes time depending on the number of pixels, but for most uses that's not an issue.

User avatar
ArchiPants
 
Posts: 7
Joined: Tue Nov 03, 2015 12:25 am

Re: how to control individual neopixels on neopixel ring

Post by ArchiPants »

Is setPixelColor available in the CircuitPython library for Neopixels?

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

Return to “Glowy things (LCD, LED, TFT, EL) purchased at Adafruit”