Addressable LED sketches freezing on a solid color after completing the sketch.

Hey there,
I am trying to upload a sketch to my meduino mega 2560 pro mini, and it successfully runs the sketch, but gets stuck at the end, freezes on a solid color, and does not loop. This is happening with more than one board that i’ve setup, and its also happening with multiple sketches that I’ve tried. Any ideas on what might be causing this? Below is the script I’ve used to test it…

#include “FastLED.h”

#define NUM_LEDS 300
#define PIN 31


void setup() {
FastLED.addLeds<WS2812B, PIN, RGB>(leds, NUM_LEDS);

void loop() {
for(int j = 0; j < 256; j++) {
for(int i = 0; i < NUM_LEDS; i++) {
leds = Scroll((i * 256 / NUM_LEDS + j) % 256);

  • }*
  • delay(1); *
  • }*
    // WS2812B LED Strip switches Red and Green
    CRGB Scroll(int pos) {
  • CRGB color (0,0,0);*
  • if(pos < 85) {*
  • color.g = 0;*
    _ color.r = ((float)pos / 85.0f) * 255.0f;_
  • color.b = 255 - color.r;*
  • } else if(pos < 170) {*
    _ color.g = ((float)(pos - 85) / 85.0f) * 255.0f;_
  • color.r = 255 - color.g;*
  • color.b = 0;*
  • } else if(pos < 256) {*
    _ color.b = ((float)(pos - 170) / 85.0f) * 255.0f;_
  • color.g = 255 - color.b;*
  • color.r = 1;*
  • }*
  • return color;*

OK, first things first.

You need to go and read the forum instructions so that you can go back and modify your original post (not re-post it) - using the “More → Modify” option below the right hand corner of your post - to mark up your code as such using the “</>” icon in the posting window. Just highlight each section of code (or output if you need to post that) from the IDE and click the icon.

In fact, the IDE has a “copy for forum” link to put these markings on a highlighted block for you so you then just paste it here in a posting window. But even before doing that, don’t forget to use the “Auto-Format” (Ctrl-T) option first to make it easy to read. If you do not post it as “code” it can as you now see, be quite garbled and is always more difficult to read.

It is inappropriate to attach it as a “.ino” file unless it is clearly too long to include in the post proper. People can usually see the mistakes directly and do not want to have to actually load it in their own IDE. And that would also assume they are using a PC and have the IDE running on that PC.

Also tidy up your blank space. Do use blank lines, but only between complete functional blocks.

How are you powering the circuit? Please post a schematic.