By using an external power supply to power the LEDs and arduino or by powering the LEDs and shift registers with a seprate supply. Join the grounds but not the plus.
Most LEDs have a continuous on limit of 20mA, not 40. Check your spec.
74HC595 also has a limit of 70mA thru the device.
You're better off withTPIC6B595 to sink current from the LEDs.
TPIC6B595N, 82 cents at avnet.com
I DON'T THINK YOU WOULD EVEN REALLY NEED A SHIFT REGISTER IF YOU WANT TO CONTROL ALL THOSE LEDS. The Arduino has more than 20 pins (i think most have a bigger number than that), which are enough for your individually controlled 16 LED's and another pin to control all the street lights at the same time.Which makes it only 17 out of 20 pins used.
Just saying..
Yes, but if using an Arduino you run into the problem of total current draw limit thru the part as well. External high-current capable shift registers take care of that. Need something off board for the transistors any, so add 2 more chips and make life easier electrically.
Only Mega's have more than 20 IO. Way less to add two 82 cent shift registers vs whatever an mega costs.
As Crossroads suggests, if you use 3 TPIC6B595s, not only do you cut down on wiring ( only 3 wires to the Arduino board ) but you could also use 4 wires and dim them with pulse width modulating the blanking pins of the TPICs ( notG pin ).
We don't know the age of your " village" but it would leave spare pins for sequenced traffic lights, shop windows etc ?
And as Grumpy Mike suggests, if you use a seperate power supply, once you have it running you can put a 24 pin socket, a 5 volts regulator, a few caps and a resistor, and you have an embedded micro, to free your Arduino board....
Personally I would not bother with the shift registers or external power. The cheapest way would be multiplex the LEDs - you just need 12 pins for 36 LEDs. You can switch em fast in arduino as long as arduino doesn't need any other thinking time. This way your using max 6 leds @ 40mA (240mA) at one time so your power will be fine, its just whether or not they will be bright enough for you.
Good luck and let us know how it all works out!
Disclaimer: Clearly I know next to nothing about electronics!