FastLED code working without Ethernet code, doesn't work with it.

I have a WS2811 LED strip that I got working with FastLED. I want to fill it static rainbow when I send a UDP packet. Making it rainbow works with this code:

#include "FastLED.h"
#define LED_PIN 52
#define NUM_LEDS 150
#define LED_TYPE WS2811
#define COLOR_ORDER BRG
CRGB leds[NUM_LEDS];


void setup() {
  LEDS.addLeds<LED_TYPE, LED_PIN, COLOR_ORDER>(leds, NUM_LEDS);
}

void loop() {
  fill_rainbow(leds, NUM_LEDS, 0, 5);
  FastLED.show();
}

but not this

/*
#include "FastLED.h"
#define LED_PIN 52
#define NUM_LEDS 150
#define LED_TYPE WS2811
#define COLOR_ORDER BRG
CRGB leds[NUM_LEDS];


#include <Ethernet.h>
#include <EthernetUdp.h>

// Enter a MAC address and IP address for your controller below.
// The IP address will be dependent on your local network:
byte mac[] = {
  0xDE, 0xAD, 0xBE, 0xEF, 0xFE, 0xED
};
IPAddress ip(192, 168, 1, 177);

unsigned int localPort = 8888;      // local port to listen on

// buffers for receiving and sending data
char packetBuffer[UDP_TX_PACKET_MAX_SIZE];  // buffer to hold incoming packet,
char ReplyBuffer[] = "acknowledged";        // a string to send back

// An EthernetUDP instance to let us send and receive packets over UDP
EthernetUDP Udp;

void setup() {
  LEDS.addLeds<LED_TYPE, LED_PIN, COLOR_ORDER>(leds, NUM_LEDS);
  // You can use Ethernet.init(pin) to configure the CS pin
  //Ethernet.init(10);  // Most Arduino shields
  //Ethernet.init(5);   // MKR ETH shield
  //Ethernet.init(0);   // Teensy 2.0
  //Ethernet.init(20);  // Teensy++ 2.0
  //Ethernet.init(15);  // ESP8266 with Adafruit Featherwing Ethernet
  //Ethernet.init(33);  // ESP32 with Adafruit Featherwing Ethernet

  // start the Ethernet
  Ethernet.begin(mac, ip);

  // Open serial communications and wait for port to open:
  Serial.begin(9600);
  while (!Serial) {
    ; // wait for serial port to connect. Needed for native USB port only
  }

  // Check for Ethernet hardware present
  if (Ethernet.hardwareStatus() == EthernetNoHardware) {
    Serial.println("Ethernet shield was not found.  Sorry, can't run without hardware. :(");
    while (true) {
      delay(1); // do nothing, no point running without Ethernet hardware
    }
  }
  if (Ethernet.linkStatus() == LinkOFF) {
    Serial.println("Ethernet cable is not connected.");
  }

  // start UDP
  Udp.begin(localPort);
}

void loop() {
  fill_rainbow(leds, NUM_LEDS, 0, 5);
  FastLED.show();
  delay(3000);
  leds[0] = CRGB(46,255,0);
  leds[1] = CRGB(0,212,255);
  leds[2] = CRGB(0,212,255);
  leds[3] = CRGB(0,0,0);
  leds[4] = CRGB(255,0,0);
  leds[5] = CRGB(255,0,212);
  leds[6] = CRGB(0,0,0);
  fill_solid( &(leds[7]), 15, CRGB( 255, 255, 255) );
  FastLED.show();
  delay(3000);
  // if there's data available, read a packet
  int packetSize = Udp.parsePacket();
  if (packetSize) {
    Serial.print("Received packet of size ");
    Serial.println(packetSize);
    Serial.print("From ");
    IPAddress remote = Udp.remoteIP();
    for (int i=0; i < 4; i++) {
      Serial.print(remote[i], DEC);
      if (i < 3) {
        Serial.print(".");
      }
    }
    Serial.print(", port ");
    Serial.println(Udp.remotePort());

    // read the packet into packetBufffer
    Udp.read(packetBuffer, UDP_TX_PACKET_MAX_SIZE);
    Serial.println("Contents:");
    Serial.println(packetBuffer);

    // send a reply to the IP address and port that sent us the packet we received
    Udp.beginPacket(Udp.remoteIP(), Udp.remotePort());
    Udp.write(ReplyBuffer);
    Udp.endPacket();
  }
  delay(10);
}

The LED strip just completely goes crazy. Any ideas on why?

It looks like you're using an Arduino Mega. Is that correct?

The Ethernet library communicates with the Ethernet controller over SPI. On the Mega, the SPI bus is on pins 50-52. The Ethernet library also uses pin 10 for CS, though this is configurable. So the problem is that you are using pin 52 for your LED strip in addition to communication with the Ethernet controller. Move your LED strip to a different pin and the problem should be solved.

Thanks so much! That fixed it.

You're welcome. I'm glad to hear it's working now. Enjoy!
Per