How to switch an external circuit with Arduino? I have an object with a series of led and I want to turn on and off these leds from my Arduino. The input of the LED circuit is 24v DC 100mA.

What I've done is the following:


I've cut a wire of this object and I connected one end to the collector and the other end to the emitter of a NPN transistor
I connected the base of the transistor to a digital output (through a 1k resistance)
I connected the power to the led series while the digital pin was LOW (actually completely disconnected)


But with no current on the base of the transistor, the LED has turned on to my surprise. I may have completely misused the transistor and other items. How do I fix this circuit?
If I understand your writeup correctly, this is what you have built:







simulate this circuit &ndash; Schematic created using CircuitLab

What you didn't mention in your question is that you made a connection from Arduino ground to the base of the transistor and the seconds circuit's ground connection. I drew the extra lead 'loose' for illustration only, but you see where it should connect. Current needs a return path, it is not sufficient to only have the forward path (from Arduino through R1 and base-Q1). The return path is emitter-Q1 to Arduino-GND.

Do notice though that the two batteries / power supplies must be floating with respect to each other otherwise you're going to short them out.