Led pattern problem

So i am doing this led pattern and i have a problem:P so the pattern is 8 led blinking randomly. i want them to start out slow and then blink faster and faster until after round about 5 sec they would blink so fast they would all turn on. and after that it would start from the beginning.. this is what i came up with

int pin2 = 2; int pin3 = 3; int pin4 = 4; int pin5 = 5; int pin6 = 6; int pin7 = 7; int pin8 = 8; int pin9 = 9; int konstanta=0; long randNumber;

void setup() {

pinMode(pin2, OUTPUT); pinMode(pin3, OUTPUT); pinMode(pin4, OUTPUT); pinMode(pin5, OUTPUT); pinMode(pin6, OUTPUT); pinMode(pin7, OUTPUT); pinMode(pin8, OUTPUT); pinMode(pin9, OUTPUT);

}

void loop() {

randNumber=random(9); konstanta=0+randNumber;

digitalWrite(konstanta, HIGH); delay(30);

digitalWrite(konstanta, LOW); delay(4);

}

thanks for all your anwsers:)

i want them to start out slow and then blink faster and faster until after round about 5 sec they would blink so fast they would all turn on. and after that it would start from the beginning.. this is what i came up with

That code is going to turn a random LED on for a fixed time, then turn it off, and do nothing for a fixed time. The pins that it will turn on do not match the pins you have defined as OUTPUT, by the way. It will turn pins 0 to 8 on/off.

If you want to make the LEDs blink faster and faster, you need to get rid of the second delay, and make the first one decrease on each pass through loop, until it gets to one. Then set it back to a larger(er) value and carry on.

hm. i dont understand. i have it like this and it works from pin 2-9. all are blinking. I know i have to decrease them. that is my problem how do i do that? i cant seem to figure it out. tnx for the help:)

 randNumber=random(9);

randNumber will be assigned a value between 0 and 8.

 konstanta=0+randNumber;

konstanta will be assigned a value between 0 and 8.

   digitalWrite(konstanta, HIGH);
   delay(30); 
                 
   digitalWrite(konstanta, LOW);
   delay(4);

Some pin in the range 0 to 8 will be turned on for 30 milliseconds, then turned off, and 4 milliseconds will be wasted.

i have it like this and it works from pin 2-9. all are blinking.

Not with that code, you do not.

I know i have to decrease them. that is my problem how do i do that? i cant seem to figure it out.

Get rid of the second delay. It isn't doing anything for you. Then, instead of calling delay(30), create a new global variable, delayTime, of type unsigned long, with an initial value of 30.

Change the delay(30) to dely(delayTime). At the end of loop, add this: delayTime--; if(delayTime == 0) delayTime = 30;

When the Arduino starts, an LED will be turned on for 30 milliseconds. Then the on time will change to 29 milliseconds, and another LED will be lit. Then, the on time will change to 28, then 27, etc. When it changes to 0, that will be detected, and the on time will change back to 30 for one cycle.