Can anyone tell me why I can't seem to get the random numbers to give any value besides the low limit?
Full code:
#include <FastLED.h>
#define LED_PIN 9 // data pin
#define NUM_LEDS 50
#define COLOR_ORDER GRB
#define LED_TYPE WS2811
#define MAX_BRIGHTNESS 50 // watch the power!
#define FPS 50
#define FLASHES 8
CRGB leds[NUM_LEDS];
uint8_t hue = 0;
uint8_t pattern = 0;
unsigned int dimmer = 1;
unsigned long previousMillis = 0; // last time update
unsigned long interval = 30000; // interval at which to do something i.e. lightning (milliseconds)
void setup() {
FastLED.addLeds<WS2811, LED_PIN, GRB>(leds, NUM_LEDS);
FastLED.setBrightness(50);
randomSeed(analogRead(A5));
}
void loop() {
unsigned long currentMillis = millis(); //time
long randNumber = random(3, 9);
if (currentMillis - previousMillis > randNumber * interval) { //lightning trigger
previousMillis = currentMillis;
for (int flashCounter = 0; flashCounter < random8(3, FLASHES); flashCounter++)
{
if (flashCounter == 0) dimmer = 5; // the brightness of the leader is scaled down by a factor of 5
else dimmer = random8(1, 3); // return strokes are brighter than the leader
FastLED.showColor(CHSV(255, 0, 255 / dimmer));
delay(random8(10, 40)); // each flash only lasts 4-10 milliseconds
FastLED.showColor(CHSV(255, 0, 0));
if (flashCounter == 0) delay (150); // longer delay until next flash after the leader
delay(50 + random8(100)); // shorter delay between strokes
}
}
else {
for (int i = 0; i < NUM_LEDS; i++) {
leds[i] = CHSV(hue, 255, 255);
}
EVERY_N_MILLISECONDS(200) {
hue++;
FastLED.show();
}
}
}
The pertinent part in question being:
void setup() {
FastLED.addLeds<WS2811, LED_PIN, GRB>(leds, NUM_LEDS);
FastLED.setBrightness(50);
randomSeed(analogRead(A5));
}
void loop() {
unsigned long currentMillis = millis(); //time
long randNumber = random(3, 9);
if (currentMillis - previousMillis > randNumber * interval) { //lightning trigger
previousMillis = currentMillis;
always seems to give a value of 3.
What am I doing wrong?