Neopixel VS Servo need Help

Hallo Forum,

i have a big problem in an project with Neopixel and a servo.

#include <IRremote.h>     
#include <Servo.h>
#include <Adafruit_NeoPixel.h>

//=== RemoteControl ===
int recvPin = 2;                         	//IR receiver pin
IRrecv irrecv(recvPin);
decode_results results;
#define POWER 0x10EFD827
#define A 0x10EFF807                      // RCMode = 1
#define B 0x10EF7887                      // RCMode = 2
#define C 0x10EF58A7                      // RCMode = 3
#define UP 0x10EFA05F
#define DOWN 0x10EF00FF
#define LEFT 0x10EF10EF
#define RIGHT 0x10EF807F
#define SELECT 0x10EF20DF
int RCMode = 0;

//=== Servo ===
Servo fullturnServo;                        // 360 C servo turn always
const byte servoPin = 9;                    // servo pin
const byte servoStop = 90;                  // servo stop at 90
const byte servoDown = 60;
const byte servoUp = 120;
byte servoPosition = servoStop;

//=== Switch Buttons ===
const byte TopSwitchPin = 4;
const byte BottomSwitchPin = 7;
byte TopSwitchState;
byte BottomSwitchState;

//=== Adafruit NeoPixel Ring - 24 x 5050 RGBW 2x24=48 ===

#define PIN 6
#define NUM_LEDS 8
#define BRIGHTNESS 55
Adafruit_NeoPixel strip = Adafruit_NeoPixel(NUM_LEDS, PIN, NEO_GRBW + NEO_KHZ800);
int gamma[] = {
    0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,
    0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  1,  1,  1,  1,
    1,  1,  1,  1,  1,  1,  1,  1,  1,  2,  2,  2,  2,  2,  2,  2,
    2,  3,  3,  3,  3,  3,  3,  3,  4,  4,  4,  4,  4,  5,  5,  5,
    5,  6,  6,  6,  6,  7,  7,  7,  7,  8,  8,  8,  9,  9,  9, 10,
   10, 10, 11, 11, 11, 12, 12, 13, 13, 13, 14, 14, 15, 15, 16, 16,
   17, 17, 18, 18, 19, 19, 20, 20, 21, 21, 22, 22, 23, 24, 24, 25,
   25, 26, 27, 27, 28, 29, 29, 30, 31, 32, 32, 33, 34, 35, 35, 36,
   37, 38, 39, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 50,
   51, 52, 54, 55, 56, 57, 58, 59, 60, 61, 62, 63, 64, 66, 67, 68,
   69, 70, 72, 73, 74, 75, 77, 78, 79, 81, 82, 83, 85, 86, 87, 89,
   90, 92, 93, 95, 96, 98, 99,101,102,104,105,107,109,110,112,114,
  115,117,119,120,122,124,126,127,129,131,133,135,137,138,140,142,
  144,146,148,150,152,154,156,158,160,162,164,167,169,171,173,175,
  177,180,182,184,186,189,191,193,196,198,200,203,205,208,210,213,
  215,218,220,223,225,228,231,233,236,239,241,244,247,249,252,255 };


//=== SETUP ===
void setup() {

	Serial.begin(9600);
  irrecv.enableIRIn();                     // receiver start
 
	fullturnServo.attach(servoPin);
	fullturnServo.write(servoPosition);

  pinMode(TopSwitchPin, INPUT_PULLUP);
  pinMode(BottomSwitchPin, INPUT_PULLUP);

  strip.setBrightness(BRIGHTNESS);
  strip.begin();

	delay(5000);
}


void loop() {
	checkSwitches();
	getIRInput();

	setServoMove();
	setNeopixel();
}


void checkSwitches() {
  	TopSwitchState = digitalRead(TopSwitchPin);
  	BottomSwitchState = digitalRead(BottomSwitchPin);
}


void getIRInput() {

  if (irrecv.decode(&results))
  {
    if (results.value == POWER)
    {
      Serial.println("POWER");   
    }
   
    if (results.value == A)
    {
      RCMode = 1;
      Serial.println("A");   
    }
   
     if (results.value == B)
    {
      RCMode = 2;
      Serial.println("B"); 
    }
   
     if (results.value == C)
    {
      RCMode = 3;
      Serial.println("C");
    }
   
     if (results.value == UP)
     {
        if (RCMode == 1) {
          servoPosition = servoUp;
        }
      Serial.println("UP");
     }
     
     if (results.value == DOWN)
    {
        if (RCMode == 1) {
          servoPosition = servoDown;
        }
      Serial.println("DOWN");
    }
     if (results.value == LEFT)
    {
      Serial.println("LEFT");
    }
     if (results.value == RIGHT)
    {
      Serial.println("RIGHT");
    }
     if (results.value == SELECT)
    {
      Serial.println("SELECT");
      if (RCMode == 1) {
        servoPosition = servoStop;
      }
    }
    irrecv.resume();
  }
}


void setServoMove() {
  if (RCMode == 1) {
   
	  if (TopSwitchState == HIGH && BottomSwitchState == HIGH) {
  		// servo can go up and down
	  }

	  if (TopSwitchState == LOW) {
		  // servo can only go down
		  servoPosition = servoStop;
      Serial.println("STOP SERVO");
	  }
   
    if (TopSwitchState == LOW && results.value == UP) {
      // servo can only go down
      servoPosition = servoStop;
      Serial.println("STOP SERVO");
    }

    if (TopSwitchState == LOW && results.value == DOWN) {
      // servo can only go down
      servoPosition = servoDown;
      Serial.println("SERVO GO DOWN");
    }
 
    if (BottomSwitchState == LOW) {
      // servo can only go up
      servoPosition = servoStop;
      Serial.println("STOP SERVO");
    }

    if (BottomSwitchState == LOW && results.value == DOWN) {
      // servo can only go up
      servoPosition = servoStop;
      Serial.println("STOP SERVO");
    }
 
    if (BottomSwitchState == LOW && results.value == UP) {
      // servo can only go up
      servoPosition = servoUp;
      Serial.println("SERVO GO UP");
    }
   
    Serial.println(servoPosition);
	  fullturnServo.write(servoPosition);
  }
}

void setNeopixel() {
 
    pulseWhite(10);
}

void pulseWhite(uint8_t wait) {
  for(int j = 0; j < 256 ; j++){
      for(uint16_t i=0; i<24; i++) {
          strip.setPixelColor(i, strip.Color(0,0,0, gamma[j] ) );
          strip.setPixelColor(47-i, strip.Color(0,0,0, gamma[j] ) );
        }
        delay(wait);
        strip.show();
      }

  for(int j = 255; j >= 0 ; j--){
      for(uint16_t i=0; i<strip.numPixels(); i++) {
          strip.setPixelColor(i, strip.Color(0,0,0, gamma[j] ) );
        }
        delay(wait);
        strip.show();
      }
}

The Neopixel do what they should, but i have also

  1. a small twitch and move of the servo
  2. no response from the Remote
    (i thing the neopixel makes the arduino to slow, there is also no info in the Seriell monitor)

I think normaly there should be no problem with this combination?

Did someone have a soution ?
Should i better use fastLED
did fastLED works with RGBW LEDs ?

Thank you for your help.

So the problem with using sk6812 rgbw or ws2812, is that the bitbanging requires precise timings, hence the interrupts are all off. That likely screws up your clocks a bit and lags the rest of your code. It might be best to grab some APA102's which don't require I believe to hog the interrupts... That would be "dotstar" in adafruit parlance, and for them, a different library.

I heard fastLED did not support 4byte but maybe they fixed that IDK.

I'd propose the LED library I'm writing, FAB_LED, but in your case it would not help.

Oops... I see your issue: You have a delay in you led display.

You need to look into nick gammon's thread "how to do many things at the same time".

In other words, you don't want to use delay(). You want to go back to loop() after display(), and come back often to check if the time has elapsed, in which case do another display with a decremented j.