Tell me more ×
Electrical Engineering Stack Exchange is a question and answer site for electronics and electrical engineering professionals, students, and enthusiasts. It's 100% free, no registration required.

Most the documentation I have found is using print for a random number generator but I can't get an idea of what to do. I need it for an array of leds. If someone has an idea of where to start let me know.

Edit1:

I'm trying to slow down a cycle of leds using randomseed(). I want to randomly choose a time in the array led cycle to slow down for 1 second. As you see I think I have the time issue sorted? Now I need to do the randomseed but I don't have a clue and anything I find to help is with numbers and print.

 randomSeed (analogRead (0));
 long oldperiod=period; // remember old period
 period=4500000;// set new slow period
 Timer1.setPeriod(period);// make it so
 delay(1000); //1 sec
 period=oldperiod; // put old period back
 Timer1.setPeriod(period); // make it so

can I use this somehow?

randOn = random (100, 1200);    // generate ON time between 0.1 and 1.2 seconds
randOff = random (200, 900);    // generate OFF time between 0.2 and 0.9 seconds
digitalWrite(ledPin, HIGH);   // sets the LED on
delay(randOn);                // waits for a random time while ON
digitalWrite(ledPin, LOW);    // sets the LED off
delay(randOff);               // waits for a random time while OFF
share|improve this question
What behavior do you want from the LEDs? – Ignacio Vazquez-Abrams Aug 18 '12 at 21:08
Please read my edit 1. Sorry for making it not clear but I didn't want to over confuse people with too much as its difficult for me too explain. Thanks – Mr Men Aug 18 '12 at 21:26
Can you count how many cycles have occurred since an event? – Ignacio Vazquez-Abrams Aug 18 '12 at 21:30
Sorry I dont understand, counting from which event? Ill add my full code so you can see – Mr Men Aug 18 '12 at 21:36
An event. Any event. We'll worry about triggering it after. – Ignacio Vazquez-Abrams Aug 18 '12 at 21:36
show 5 more comments

Know someone who can answer? Share a link to this question via email, Google+, Twitter, or Facebook.

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Browse other questions tagged or ask your own question.