I have an array which stores some uint32_t neopxiel colors: red, green, blue, and yellow:
uint32_t colorRed = pixels.Color(255, 0, 0);
uint32_t colorGreen = pixels.Color(0, 150, 0);
uint32_t colorBlue = pixels.Color(0, 255, 255);
uint32_t colorYellow = pixels.Color(255, 255, 0);
uint32_t colorArray[4] = {colorRed, colorGreen, colorBlue, colorYellow};
Then I want to make an array that holds these colors in random order every time the arduino starts up.
uint32_t patternArray[4] = {colorArray[random(4)], colorArray[random(4)], colorArray[random(4)], colorArray[random(4)]};
This seems to have made a random order of those 4 colors, but it is the same "random" order every time the arduino starts up (yellow, green, green, blue).
How do I make that random order different every time the arduino starts up?
I've tried declaring a placeholder array and initializing it after the randomSeed(0) thing that most forum posts suggest, but I can't seem to get the right syntax for declaring the array and then later assigning values to it:
//uint32_t patternArray; //nope
//uint32_t patternArray[4]; //nope
setup(){
randomSeed(analogRead(0));
//patternArray = {colorArray[random(4)], colorArray[random(4)], colorArray[random(4)], colorArray[random(4)]}; //nope
patternArray[4] = {colorArray[random(4)], colorArray[random(4)], colorArray[random(4)], colorArray[random(4)]}; //nope
}
Aucun commentaire:
Enregistrer un commentaire