twinkle led's

hi all
i know the mega wich i have has got Digital I/O Pins 54 (of which 15 provide PWM output)
can i get all the 54 pins to twinkle an individual led like stars in the sky at night in a random pattern ??
or what would be the better alternative?

Yes, you can have each pin twinkle one LED. Using a higher voltage power source and a transistor for switching you can have each pin twinkle a set of multiple LEDs. If you spread the members of the set over a wide area it should not be obvious that several are blinking synchronously.

Using multiplexing you can have N pins control (N/2)^2 LEDs (50 pins = 625 LEDs). You will need N/2 drive transistors.

Using Charlieplexing you can have N pins control N^2-N LEDs (50 pins = 2450 LEDs). You will only be able to light one at a time.

would this sketch be ok once i mod it ?
http://joesgizmos.wordpress.com/2012/07/06/twinkle-leds/

i'm getting in to multiplexing soon

markthespark:
would this sketch be ok once i mod it ?
http://joesgizmos.wordpress.com/2012/07/06/twinkle-leds/

i'm getting in to multiplexing soon

If you use an array like:

const int LED_Pins[] = {2,3,4,5,6,7,8,9,10};

instead of :

#define LED1 2
#define LED2 3
#define LED3 4
#define LED4 5
#define LED5 6
#define LED6 7
#define LED7 8
#define LED8 9
#define LED9 10

it will be much easier to expand and easier to manipulate LEDs by index.