light three LEDs randomly with a progressive ignition

Hello,

i’m novice with the programming of an arduino. I would like to light three LEDs randomly with a progressive ignition. I managed to make a progressive ignition, but I can’t light the LEDs randomly with the code that I already wrote

Maybe my base is not adapted to put then a random function ?..

int R = 6; //red
int B = 11; //blue
int J = 10; //yellow
int V = 9; //green

int c = 0; // cycle

void setup() {
pinMode (R, OUTPUT);
pinMode (B, OUTPUT);
pinMode (J, OUTPUT);
pinMode (V, OUTPUT);
}

void loop() {
allumeLed(); //high
eteindreLed(); //low
}

void allumeLed() {
for (c = 0; c <= 255; c++)
{
analogWrite (R, c);
analogWrite (V, c);
analogWrite (B, c);
analogWrite (J, c);

delay(random(20, 150));
}
}

void eteindreLed() {
for (c = 255; c >= 0; c–)
{
analogWrite (R, c);
analogWrite (V, c);
analogWrite (B, c);
analogWrite (J, c);

delay(10);
}
}

OK, first things first.

You need to go and read the forum instructions so that you can go back and modify your original post (not re-post it) - using the “More → Modify” option below the right hand corner of your post - to mark up your code as such using the “</>” icon in the posting window. Just highlight each section of code (or output if you need to post that) from the IDE and click the icon.

In fact, the IDE has a “copy for forum” link to put these markings on a highlighted block for you so you then just paste it here in a posting window. But even before doing that, don’t forget to use the “Auto-Format” (Ctrl-T) option first if you have not already done so to make it easy to read. When you do not post it as “code” it can easily be quite garbled and is always more difficult to read.

It is inappropriate to attach it as a “.ino” file unless it is clearly too long to include in the post proper. People can usually see the mistakes directly and do not want to have to actually load it in their own IDE. And that would also assume they are using a PC and have the IDE running on that PC.

Also tidy up your blank space. Do use blank lines, but only between functional blocks.

The random delay is being averaged over 256 steps, so it will be way less random than
you think.

You perhaps need random steps in brightness, not random delays between tiny steps.