Voting resources, early voting, and poll worker information - VOTE. ... Adafruit is open and shipping.
0

Trying to use Arduino to control Neopixels and light a seven
Moderators: adafruit_support_bill, adafruit

Please be positive and constructive with your questions and comments.

Trying to use Arduino to control Neopixels and light a seven

by seanspotatobusiness on Mon Aug 03, 2020 6:56 am

I am trying to use an Arduino Nano to control some Neopixels where a potentiometer controls the number of pixels illuminated. I also would like a seven-segment display to show the number of LEDs that the Arduino is set to illuminate. I have modified the Adafruit strandtest.h Sketch as follows, removing the delay(wait); and inserting 2000 refreshes of the seven-segment display. The problem is that the seven-segment display flickers. It's perfectly readable; it just doesn't look very nice. Is this likely to be because the rainbowCycle function spends too long on the Neopixel bit to avoid this? Is there any easy way around it? Thanks.

Code: Select all | TOGGLE FULL SIZE
void rainbowCycle(uint8_t wait) {
  uint16_t i, j, b;

  for (j = 0; j < 256 * 5; j++) { // 5 cycles of all colors on wheel
    for (i = 0; i < NUM_RAINBOW_LEDS; i++) {
      strip->setPixelColor(i, Wheel(((i * 256 / NUM_RAINBOW_LEDS) + j) & 255));
    }
    strip->show();
    sevseg.setNumber(map(analogRead(potentiometerPin), 0, 1023, 300, 1));
    for (b = 0; b < 2000; b++) {
      sevseg.refreshDisplay(); // Must run repeatedly
    }
  }
}

// Input a value 0 to 255 to get a color value.
// The colours are a transition r - g - b - back to r.
uint32_t Wheel(byte WheelPos) {
  WheelPos = 255 - WheelPos;
  if(WheelPos < 85) {
    return strip.Color(255 - WheelPos * 3, 0, WheelPos * 3);
  }
  if(WheelPos < 170) {
    WheelPos -= 85;
    return strip.Color(0, WheelPos * 3, 255 - WheelPos * 3);
  }
  WheelPos -= 170;
  return strip.Color(WheelPos * 3, 255 - WheelPos * 3, 0);
}

seanspotatobusiness
 
Posts: 30
Joined: Tue Mar 15, 2016 7:33 am

Re: Trying to use Arduino to control Neopixels and light a s

by adafruit_support_bill on Mon Aug 03, 2020 7:17 am

How long is your neopixel strip and what are you using to drive your seven segment display?
The problem is most likely the time that it takes to update the neopixels results in a gap in your display refresh. You could use something like an HT16K33 display driver to handle the refresh automatically. We have these on a breakout board as well as backpacks for 0.56" and 1.2" displays.

https://learn.adafruit.com/adafruit-led-backpack

adafruit_support_bill
 
Posts: 78633
Joined: Sat Feb 07, 2009 10:11 am

Re: Trying to use Arduino to control Neopixels and light a s

by seanspotatobusiness on Tue Aug 04, 2020 4:12 am

adafruit_support_bill wrote:How long is your neopixel strip and what are you using to drive your seven segment display?
The problem is most likely the time that it takes to update the neopixels results in a gap in your display refresh. You could use something like an HT16K33 display driver to handle the refresh automatically. We have these on a breakout board as well as backpacks for 0.56" and 1.2" displays.

https://learn.adafruit.com/adafruit-led-backpack


I'm using an 8-LED Neopixel stick for prototyping but I want to ultimately be able to control up to 300 LEDs. I'm currently using 10 pins on the Arduino to control the display. I will probably just put up with the flickering for now since it won't be in this mode often but it's good to know about this I2C backpack option for the future, thanks.

seanspotatobusiness
 
Posts: 30
Joined: Tue Mar 15, 2016 7:33 am

Re: Trying to use Arduino to control Neopixels and light a s

by adafruit_support_bill on Tue Aug 04, 2020 5:33 am

8 pixels shouldn't take too long to update. But 300 pixels will take a bit longer and might increase the visible flicker.

adafruit_support_bill
 
Posts: 78633
Joined: Sat Feb 07, 2009 10:11 am

Please be positive and constructive with your questions and comments.