Thanks John! Although this way I won't be able to use shift registers won't I? because in my final project I will be using 27 LED's. But that's not to big of a problem, in that case I will use I2C I/O expanders.

You can use an unsigned long (32-bit integer) to keep track of which LEDs you want on and off.

So i thought this did the trick since I tested it with one shift register (register pin 0 - 7), today I tried daisy chaining an other one to it (register pin 0 - 15). And I ran in to the same problem: most of the time the desired amount of LEDs are burning but about 10% of the time a couple of them don't light up (I guess it has some thing to do with the pattern being full or something?). Is there a fix for this?

thisPin = random(8) to a higher number, (starting to use the second shift register, which is a 74HC595 by the way) I get the problem (most of the time the desired amount of LEDs are burning but about 10% of the time a couple of them don't light up)

The code looks OK. Have you checked to see that all of the lights work? Watch each light for 10 seconds or until if comes on. It might be that one or more of your LEDs is not working (bad connection) and so the random patterns will sometimes hit a non-working LED.

The code looks OK. Have you checked to see that all of the lights work? Watch each light for 10 seconds or until if comes on. It might be that one or more of your LEDs is not working (bad connection) and so the random patterns will sometimes hit a non-working LED.