blink neopixel randomly

Hi all,

i have a code that lets a pair of neopixels blink for 500 millisecond each. i want to randomize this value and used a random function for this. however, it seems to blink om a random time, but it doesn’t change. the time stays the same for every loop. i am using the blink without delaty type coding, since i want to let my arduio multitask. i’m a bit new to this blink without delay thing, so excuse my noob question.

P.S. this code is a mess, but i will clean it up once i have everything running! the blinking function this question is about is in “void NeoBlink”! the code under that is the main code. i really hope you guys can help me.

void NeoBlink(int num, int wait)
{
  long interval1 = random(1,500);           // interval at which to blink (milliseconds)
  long interval2 = 2000;           // interval at which to blink (milliseconds)
  unsigned long currentMillis = millis();
if(currentMillis - previousMillis > interval1) {
  for (int i = 2; i < num; i++)
  {
    LargeLogicPixels.setPixelColor(i, 0, 0, 255);
  }
  LargeLogicPixels.show();
}
  if(currentMillis - previousMillis > interval2) {
    previousMillis = currentMillis; 
  for (int j = 2; j < num; j++)
  {
    LargeLogicPixels.setPixelColor(j, 0, 255, 0);
  }
  LargeLogicPixels.show();
  }
}
/*
  NeoPixel LEDs

  modified on 7 May 2019
  by Saeed Hosseini @ Electropeak
**This code is based on Adafruit NeoPixel library Example**
  https://electropeak.com/learn/

*/

#include <Adafruit_NeoPixel.h>
#ifdef __AVR__
#include <avr/power.h> // Required for 16 MHz Adafruit Trinket
#endif

#define RearLogic_PIN         5
#define LargeLogic_PIN        6
#define RadarEye_PIN          11
#define PSI_PIN               10
#define HP_PIN                3

#define RearLogic_NUMPIXELS   2
#define LargeLogic_NUMPIXELS  4
#define RadarEye_NUMPIXELS    1
#define PSI_NUMPIXELS         1
#define HP_NUMPIXELS          1

Adafruit_NeoPixel RearLogicPixels(RearLogic_NUMPIXELS, RearLogic_PIN, NEO_GRB + NEO_KHZ800);
Adafruit_NeoPixel LargeLogicPixels(LargeLogic_NUMPIXELS, LargeLogic_PIN, NEO_GRB + NEO_KHZ800);
Adafruit_NeoPixel RadarEyePixels(RadarEye_NUMPIXELS, RadarEye_PIN, NEO_GRB + NEO_KHZ800);
Adafruit_NeoPixel PSIPixels(PSI_NUMPIXELS, PSI_PIN, NEO_GRB + NEO_KHZ800);
Adafruit_NeoPixel HPPixels(HP_NUMPIXELS, HP_PIN, NEO_GRB + NEO_KHZ800);

long previousMillis = 0;        // will store last time LED was updated


void setup() {
  RearLogicPixels.begin();
  LargeLogicPixels.begin();
  RadarEyePixels.begin();
  PSIPixels.begin();
  HPPixels.begin();
}

void loop() {
  
  
  RearLogicPixels.clear();
  RearLogicPixels.setBrightness(255);
  RearLogicPixels.setPixelColor(0, RearLogicPixels.Color(8, 8, 255));
  RearLogicPixels.setPixelColor(1, RearLogicPixels.Color(8, 8, 255));
  RearLogicPixels.show();

  LargeLogicPixels.clear();
  LargeLogicPixels.setBrightness(255);
  LargeLogicPixels.setPixelColor(0, LargeLogicPixels.Color(125, 200, 255));
  LargeLogicPixels.setPixelColor(1, LargeLogicPixels.Color(125, 200, 255));
  NeoBlink(4,500);
//  LargeLogicPixels.setPixelColor(2, LargeLogicPixels.Color(0, 0, 0));
//  LargeLogicPixels.setPixelColor(3, LargeLogicPixels.Color(0, 0, 0));
//  LargeLogicPixels.show();
  
//if(millis() - randomMillis > 1000) {
//      int random_i = random(0,6);
//      LargeLogicPixels.setPixelColor(random_i, LargeLogicPixels.Color(random(0,255),random(0,255),random(0,255))); 
//      LargeLogicPixels.show();
//      randomMillis = millis();
//}

  RadarEyePixels.clear();
  RadarEyePixels.setBrightness(255);
  RadarEyePixels.setPixelColor(0, RadarEyePixels.Color(0, 255, 0));
  RadarEyePixels.show();
  
  HPPixels.clear();
  HPPixels.setBrightness(255);
  HPPixels.setPixelColor(0, HPPixels.Color(0, 0, 255));  
  HPPixels.show();

//  PSIBlink();
  
//  PSIPixels.clear();
//  PSIPixels.setBrightness(255);
//  PSIPixels.setPixelColor(0, PSIPixels.Color(255, 255, 255));
//  PSIPixels.show();
//  delay(random(20,150));
//  PSIPixels.setPixelColor(0, PSIPixels.Color(0, 0, 0));
//  PSIPixels.show();
//  delay(random(100,400));
//  PSIPixels.setPixelColor(0, PSIPixels.Color(255, 255, 255));
//  PSIPixels.show();
//  delay(random(100,200));
//  PSIPixels.setPixelColor(0, PSIPixels.Color(0, 0, 0));
//  PSIPixels.show();
//  delay(random(100,400));
//  PSIPixels.setPixelColor(0, PSIPixels.Color(255, 255, 255));
//  PSIPixels.show();
//  delay(random(50,200));
//  PSIPixels.setPixelColor(0, PSIPixels.Color(0, 0, 0));
//  PSIPixels.show();
//  delay(random(4000,7000));
  
}

Google:
random seed Arduino

Also
random(1,500);
Try
random(100, 500);

Thank you for the reply! I tried 100,500 but that didn't solve the problem. I'll look into randomseed!

1,500

The point was 1ms was too fast to see ;).

A visit to http://snippets-r-us.com in the near future would be a good idea.

Knowing what the function does, without knowing how it is called is useless.