Need some help With coding a ws2812b project

I added the print code just as you said

here is an example of where I put the code

void anim4(CRGB color) {
  Serial.println (4);
  //
  byte cligno = 5;
  for (int k = 0; k < cligno; k++) {
    for (int i = 0; i < NUM_LEDS3 / 2; i++) {
      leds3[i] = color;
      leds3[NUM_LEDS3 - i] = color;
      FastLED.show();
      delay(30);
    }
    for (int i = NUM_LEDS3 / 2; i > 0; i++) {
      leds3[i - 1] = CRGB::Black;
      leds3[NUM_LEDS3 - i + 1] = CRGB::Black;
      FastLED.show();
      delay(30);
    }
  }
}
void loop () {
  FastLED.clear();
  FastLED.show();
  int bet = selectinner();
  int wheel = outerwheel ();
  CRGB colour = (bet == wheel / 3) ? CRGB::Green : CRGB::Red;
  Serial.print(colour.r);
  Serial.print("\t");
  Serial.println(colour.g);
  int numAnim = random(N_ANIM);
  Serial.println (numAnim) ;
  animation[numAnim](colour);
  if  (bet == wheel / 3) doodle();
  else theFur();
  while (digitalRead (button)) {}
  delay (100);
}

If you win, the value of colour is CRGG::Green and CRGB::Red if you lose.
colour.r is the 'red' value of colour and the same for g and green. If you win you should get 0 and 255 and if you lose 255 and 0.

You can see if you win or lose, not me... So you can tell me if the chosen color is correct or not, assuming 2¿ means 255...

Did you set the console speed to 9600 bauds?

The code is correct. Please tell me what the console says.

lesept:
The code is correct. Please tell me what the console says.

Yes it is set at 9600

it says

2?0 0 2?0 2?2?2?2?0

The third strip does not light up at all
when there is a match it reports the 0
and causes a space before next 2 or 0
instead of line down it just goes horizontally accross the monitor

So I was wrong with these three prints, delete them... :frowning:

Let's stick to the animations number
Keep the print of numAnim and tell me if it prints twice

Do you still have the music?

lesept:
Do you still have the music?

no, hey I got it to work, I changed the radom() to my pRNG and now it all runs correctly one sad note is the music plays after the light show and not during it:( but I guess that cant be corrected
the serial print works perfect and its giving the number of the animation

if we could end each animation with all the lights on that would look great so the music plays while lights are lit

I don't understand why it doesn't work as it used to in my previous code...

So instead of

animation[numAnim](colour)

Let's change for something more classical (keep the previous version, just comment that line), put

   if (numAnim == 0) anim1(colour);
    else if (numAnim == 1) anim2(colour);
    else if (numAnim == 2) anim3(colour);
    else if (numAnim == 3) anim4(colour);

lesept:
I don't understand why it doesn't work as it used to in my previous code...

So instead of

animation[numAnim](colour)

Let's change for something more classical (keep the previous version, just comment that line), put

   if (numAnim == 0) anim1(colour);

else if (numAnim == 1) anim2(colour);
   else if (numAnim == 2) anim3(colour);
   else if (numAnim == 3) anim4(colour);

It is working now all as intended, using pRNG instead of random and mapping the value from 0 to 3 did the trick

int numAnim = prng.getRndByte();
  numAnim = map(numAnim, 0, 255, 0, 3);

that change made it work as intended. There are 4 animations and then the music plays. thank you.

Great!
You can easily add any animation you want.

I'll think about how to do the comet queue.

lesept:
Great!
You can easily add any animation you want.

I'll think about how to do the comet queue.

Great thank you for all the help on this one.

Ok, let's try to replace the outerwheel function by this one

int outerwheel () {
  const int mindelay = 10;
  const int maxdelay = 85;
  const byte spins = 7;
  const byte Qsize = 6;
  int spinIt = prng.getRndByte();
  spinIt = map (spinIt, 0, 255, 0, NUM_LEDS2 - 1);
  int maxnum = spins * NUM_LEDS2 + spinIt;
  int count = 0;
  for (byte i = 0; i < spins; i++) {
//    leds2[NUM_LEDS2 - 1] = CRGB::Black;
    for (byte j = 0; j < NUM_LEDS2; j++) {
      if (count >= Qsize) {
        byte prevled = j - Qsize;
        if (prevled < 0) prevled = prevled + NUM_LEDS2;
        leds2[prevled] = CRGB::Black;
      } 
      if (count >= maxnum - Qsize) {
      byte prevled = spinIt + count - maxnum - 1;
      if (prevled < 0) prevled = prevled + NUM_LEDS2;
        leds2[prevled] = CRGB::Black;
      }
      leds2[j] = CRGB::Cyan;
      FastLED.show();
      count++;
      int vardelay = map(count, 0, maxnum, mindelay, maxdelay);
      tone(9, 1000,5);
      delay(vardelay);
    }
  }
  for (byte j = 0; j < spinIt; j++) {
    if (count >= maxnum - Qsize) {
      byte prevled = spinIt + count - maxnum - 1;
      if (prevled < 0) prevled = prevled + NUM_LEDS2;
        leds2[prevled] = CRGB::Black;
      }
 //   leds2[NUM_LEDS2 - 1] = CRGB::Black;
 //   byte prevled = j - 1;
 //   if (prevled < 0) prevled = NUM_LEDS2 - 1;
 //   leds2[prevled] = CRGB::Black;
    leds2[j] = CRGB::Cyan;
    FastLED.show();
    count++;
    int vardelay = map(count, 0, maxnum, mindelay, maxdelay);
    tone(9,1000,5);
    delay(vardelay);
  }
  return spinIt;
}

And cross your fingers...

To have anim1 finish with all leds lit just add this at the very end

for (int i = 0; i < NUM_LEDS3; i++) leds3[i] = color;
    FastLED.show();

For anim2, add this

for (int i = 0; i < NUM_LEDS3; i++) {
      leds3[i] = color;
      FastLED.show();
     delay(50); 
    }

anim3 should already end with the leds lit
For anim4 add this

for (int i = 0; i<NUM_LEDS3/2; i++) {
      leds3[i] = colour;
      leds3[NUM_LEDS3-i] = colour;
      FastLED.show();
      delay(30);
    }

great that would be perfect

Do you mean it work 100%???

lesept:
Do you mean it work 100%???

The ending Leds all are solid now while playing the music

The shooting star effect is 50%

it goes around just fine but the last 6 led's they stay on while it goes around again

Please explain what you see as precisely as possible...

lesept:
Please explain what you see as precisely as possible...

Yes

The outerwheel lights up and has a chase of 6 leds, they go around

at the end of the first time around the last 6 leds of the strip stay lit.

The chase goes around and then goes through the always lit last 6

after on the seventh loop the final led looses the chase and eventually stops.

Hum. I didn't understand as you explained so I coded this

int outerwheel () {
  const int mindelay = 10;
  const int maxdelay = 85;
  const byte spins = 7;
  const byte Qsize = 6;
  int spinIt = prng.getRndByte();
  spinIt = map (spinIt, 0, 255, 0, NUM_LEDS2 - 1);
  int maxnum = spins * NUM_LEDS2 + spinIt;
  int count = 0;
  for (byte i = 0; i < spins; i++) {
//    leds2[NUM_LEDS2 - 1] = CRGB::Black;
    for (byte j = 0; j < NUM_LEDS2; j++) {
      if (count >= Qsize) {
        byte prevled = j - Qsize;
        if (prevled < 0) prevled = prevled + NUM_LEDS2;
        leds2[prevled] = CRGB::Black;
      } 
      leds2[j] = CRGB::Cyan;
      FastLED.show();
      count++;
      int vardelay = map(count, 0, maxnum, mindelay, maxdelay);
      tone(9, 1000,5);
      delay(vardelay);
    }
  }
  for (byte j = 0; j < spinIt; j++) {
    byte prevled = j - Qsize;
    if (prevled < 0) prevled = prevled + NUM_LEDS2;
    leds2[prevled] = CRGB::Black;
    leds2[j] = CRGB::Cyan;
    FastLED.show();
    count++;
    int vardelay = map(count, 0, maxnum, mindelay, maxdelay);
    tone(9,1000,5);
    delay(vardelay);
  }
  for (int i=1;i<Qsize;i++) {
    byte prevled = spinIt - Qsize + i - 1;
    if (prevled < 0) prevled = prevled + NUM_LEDS2;
    leds2[prevled] = CRGB::Black;
    FastLED.show();
    tone(9,1000,5);
    delay(vardelay);
  } 
  return spinIt;
}

tell me...

here the error message Arduino:

1.8.4 (Linux), Board: "Arduino/Genuino Uno"

In file included from /home/bill/Arduino/lesept_animations_fork_working_A/lesept_animations_fork_working_A.ino:95:0:
/home/bill/Arduino/libraries/FastLED/FastLED.h:17:21: note: #pragma message: FastLED version 3.001.007

pragma message "FastLED version 3.001.007"

^
/home/bill/Arduino/lesept_animations_fork_working_A/lesept_animations_fork_working_A.ino: In function 'int outerwheel()':
lesept_animations_fork_working_A:306: error: 'vardelay' was not declared in this scope
delay(vardelay);
^
exit status 1
'vardelay' was not declared in this scope

This report would have more information with
"Show verbose output during compilation"
option enabled in File -> Preferences.

i just declared it locally and it is 75% right I will post a picture of the lights

The last number works better now, the chase closes in on the last led.