if i am using arduino to control 12v LED with transistor switch is it necessary to put a diode on input of that circuit to prevent current from flowing back? if it is then can you please give me a schematic example of how to put diode to good use and prevent back flowing
Not usually but you have not shown us the circuit or told us whether the transistor is bipolar or MOSFET or something else.
Unless there is something highly unusual about your application, no.
Usually you just switch the low side of the load (in this case the LED+current limiting) with an NPN BJT or N-channel MOSFET. If you must switch the high side, since it's 12v, you'll need a small NPN/N-channel transistor to switch the base/gate of the PNP/P-channel transistor that you're using to switch the load - this is one of the reasons that high side switching is used less frequently (also, PNP BJTs and P-channel fets are more expensive for a given level of performance than an NPN BJT or N-channel fet). Neither of those wiring schemes involves a diode.
Mark248:
if i am using arduino to control 12v LED with transistor switch is it necessary to put a diode on input of that circuit to prevent current from flowing back? if it is then can you please give me a schematic example of how to put diode to good use and prevent back flowing
Where would this back flowing current come from? I guess there might be a small photo current (all
LEDs also act as photodiodes), but I doubt it would be any problem.
The common case of requiring a diode is for inductive loads. Or when several alternate power supplies
can be used and you need to prevent one back-powering another.
See Step 2 in this Instructable
where I solved exactly this problem (ok, with a Raspberry Pi not an Arduino, but it'll work just as well).