Maybe this will help: Its a random ON OFF generator
int ledPin = 13; // LED connected to (digital) pin 13
long randOn = 0; // Initialize a variable for the ON time
long randOff = 0; // Initialize a variable for the OFF time
int led = 13; //ignore
int brightness = 0; //ignore
int fadeAmount = 10; //ignore
void setup() // run once, when the sketch starts
{
randomSeed (analogRead (0)); // randomize
pinMode(ledPin, OUTPUT); // sets the digital pin as output
}
void loop() // run over and over again
{
randOn = random (20, 600); // generate ON time between x seconds (fiddle with these values to get the length of time ON)
randOff = random (20, 600); // generate OFF time between y seconds (fiddle with these values to get the length of time OFF)
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
analogWrite(led, brightness); //ignore
brightness = brightness + fadeAmount; //ignore
if (brightness == 0 || brightness == 255) //ignore
fadeAmount = -fadeAmount ; //ignore
}
Moderator edit:
</mark> <mark>[code]</mark> <mark>
</mark> <mark>[/code]</mark> <mark>
tags added.