I am trying to generate random output for the leds from the given values in the array I created but it does not work, I found this online and they said do it like below but it doesn't do anything. The programme should get a random value from the array.
int randomArray[4] = { 0,85,170,255 };
void setup() {
Serial.begin(9600);
pinMode(red, OUTPUT);
pinMode(green, OUTPUT);
pinMode(blue, OUTPUT);
pinMode(RLed, OUTPUT);
pinMode(YLed, OUTPUT);
pinMode(GLed, OUTPUT);
randomSeed(millis());
}
void loop() {
redvalue = randomArray[random(0,3)];
bluevalue = randomArray[random(0, 3)];
greenvalue = randomArray[random(0, 3)];
Serial.println(redvalue);
Serial.println(bluevalue);
Serial.println(greenvalue);
analogWrite(red, redvalue);
analogWrite(blue, bluevalue);
analogWrite(green , greenvalue);
analogWrite(RLed, redvalue);
analogWrite(YLed, bluevalue);
analogWrite(GLed, greenvalue);
delay(1000);
}