Sir, i want to connect 13 relays to microcontroller nd i hav only 4 pins to connect these relays.... so i am using decoder ic to connect the outputs.... so please tell me how to program for this...
What decoder IC? Using what pins?
Presumably a 4-to-16 decoder, where you output a 4-bit binary number which reflects the relay number you wish to energize.
See also: www.catb.org/.../smart-questions.html
... i hav only 4 pins to connect these relays
Isn't that rather a huge hint that you have chosen The Wrong Microcontroller?!
It's not as if there is any shortage of microcontrollers (including 8051-based) with more than 13 output pins - even with significantly more!
Other pins are already utilized by other input output devices like lcd,keyboard,sensor thats why only 4 pins are there for relays output
and i want 5 combinations of 12 relays for different power factors settings
You could daisy chain a couple of shift registers, clock the new pattern through the chain, and then latch it.
there are '51 devices with 64 pins, why Mickey Mouse it?
But SPI-driven shift registers are quite practical. Especially since some of them have very powerful, sometimes current-controlled, outputs or open-collector outputs able to directly handle 12V relays (at least if the relays have freewheel diodes).
Cause it's a Steamboat Willie type development effort?