random led blink code check

hi all
i got a simple code and have modified it myself just want some one to check if the code is ok
i'm new at this and still learning the code

// Random flasher by mark oldroyd
// Simple random number flasher
// generation and integration into your circuit on the
// arduino.
//
// Circuit build : Simply connect 8 LED's to pins 3,4,5,6,7,8,9,10
// Be sure to connect a resistor to each LED. I used 330 ohms.
//
//
int ranNum;
int ranDel;
void setup() {
// Seed RNG from analog port.
randomSeed(analogRead(0));
// Setup 8 output ports for LED's
pinMode(3, OUTPUT);
pinMode(4, OUTPUT);
pinMode(5, OUTPUT);
pinMode(6, OUTPUT);
pinMode(7, OUTPUT);
pinMode(8, OUTPUT);
pinMode(9, OUTPUT);
pinMode(10, OUTPUT);
}
void loop() {
//Generate random number between 8 and 10
ranNum=random(3,11);
// Generate random delay time
ranDel=random(25,300);
//Turn on the LED
digitalWrite(ranNum, HIGH);
delay(ranDel);
//Turn off the LED
digitalWrite(ranNum, LOW);
}

thanks all
marko

void loop() {
    //Generate random number between 8 and 10
    ranNum=random(3,11);
    // Generate random delay time
    ranDel=random(25,300);
    //Turn on the LED
    digitalWrite(ranNum, HIGH);
    delay(ranDel);
    //Turn off the LED
    digitalWrite(ranNum, LOW);  
}

The LED is turned on, delays for a random amount of time, turned off and then within a split second, turned on again. Look at the Blink example and notice the second delay.

is this ok as i say i'm new to arduino i'm used to pic chips

//Generate random number between 8 and 10
ranNum=random(3,11);
// Generate random delay time
ranDel=random(100,400);
//Turn on the LED
digitalWrite(ranNum, HIGH);
delay(ranDel);
//Turn off the LED
digitalWrite(ranNum, LOW);

The LED is turned on, delays for a random amount of time, turned off and then within a split second, turned on again.

Yes, but hopefully, a different LED is turned on.

OP, what is the problem you're seeing, and what did you expect to see?

AWOL:

The LED is turned on, delays for a random amount of time, turned off and then within a split second, turned on again.

Yes, but hopefully, a different LED is turned on.

OP, what is the problem you're seeing, and what did you expect to see?

Good point, I totally skipped over the whole random LED part.

im looking to flash 8 led's in a slow random pattern possably fading between each flash

OK, you're missing the fade, but are you happy with the randomness?

yes im happy with the random bit i can modify it later
i would like it to fade between each phase but i'm not that good yet lol

A problem you'll run into is that you're picking pin numbers between 3 and 10 inclusive, not all of which are capable of hardware PWM, which is useful for dimming.
I'd put the PWM pin numbers into an array, and use the random number to provide an index into that array.

pins 6 to 13 ok ?

so do not use pins 5 and 6
so could i use pins 2,3,4,7,8,9,10,11 ???
i'll get there in the end

so do not use pins 5 and 6

Why not?

Did you read the page I linked?

yas i read the page and got a little confused i have a mega so it should not be a problem to me

so how do i make them fade between each phase ?

markthespark:
so how do i make them fade between each phase ?

Look at the Fade example for the code to use in place of just turning the LED off.

Hai ,

Fantastic project, this is what I was looking for to make my drawbot work autonomously

I still have a question, is it possible to burn the 2 LEDs that I use simultaneously as random

So you could choose between 1led on, or 2nd led on or both on in random

Can you help me please

int ranNum;
int ranDel;

void setup() {
 
  Serial.begin(9600);
  Serial.println("Starting new Random Number Sequence");
  
    randomSeed(analogRead(0));          // Seed RNG from analog port.

 pinMode(2, OUTPUT);                    // Setup 2 output ports for LED's
 pinMode(3, OUTPUT);
                                    
}
void loop() {
    
    ranNum=random(2,4);                 // Generate random number between 2 and 3
    ranDel=random(25,300);              // Generate random delay time 25,300
    
    digitalWrite(ranNum, HIGH);         // Turn on the LED
    delay(ranDel);
    
    digitalWrite(ranNum, LOW);          // Turn off the LED  
    delay(ranDel);

  Serial.print("The Random Number is = ");
  Serial.println(ranNum : ranDel) ;
  //Serial.print("The Random Delay is  = ");
  //Serial.println(ranDel);
  
}