No the first simpler one is perfectly OK. However that first one fails to include the required series current limiting base resistor between the output pin and the base terminal of the transistor. Damage to the driving signal and or the transistor is highly probable without it.

I don't really understand for what this first resistor is needed. Could someone explain me this? Would my solution work?

I think you mean "transistor" instead of "resistor". The answer to that question is that the second circuit can switch faster due to the potentially lower value of the base resistor, since the capacitance of the transistor junction would be able to charge and discharge faster. In practice, retrolefty's advice will no doubt work perfectly for your application. The second circuit is the classic input stage to a TTL integrated circuit and makes sense when you are building ICs because transistors and diodes take up less space on the die than resistors.

No I don't think so... There is no base bias on the second transistor (it should be a PNP) the first transistor is cut off when the emitter is high when it's low there is nothing at the collector for it to work with. This is a conceptually bad adaptation of a TTL gate input. For a thought problem set that circuit up in your mind and ground the first transistor emitter... Q: What happens?. A: Since the base has a pull-up on it, it starts conducting...Conducting What? there is no forward bias supply for the second transistor base, so nothing happens.

Bob{Edit RKJ}

--> WA7EMS "The solution of every problem is another problem." -Johann Wolfgang von GoetheI do answer technical questions PM'd to me with whatever is in my clipboard

No I don't think so... There is no base bias on the second transistor (it should be a PNP) the first transistor is cut off when the emitter is high when it's low there is nothing at the collector for it to work with. This is a conceptually bad adaptation of a ttl gate input.

Bob

Using the nomenclature from OP's circuit diagram: When the emitter of T2 is > 1.4V, T1 is biased into saturation through the 4k7 resistor and the forward biased PN junction of T2. When the emitter of T2 is low, T2 is saturated and its collector is lower than required to turn on T1 and the output is pulled up to 5V.

Where is the base bias for T1?, T2 is now on as it's emitter is lower than it's base so collector current can flow to the emitter... From Where? current cannot flow from the emitter, it's grounded. and there is no pull-up on T1's base. How is T1 ever turned on?.

Bob

This was a question I used on an employment exam for prospective electronics technicians... If the prospect got this question right, I'd read his resume, if not it got 'filed'. (I missed it once in the late 70's, applying for a job that I didn't get)

--> WA7EMS "The solution of every problem is another problem." -Johann Wolfgang von GoetheI do answer technical questions PM'd to me with whatever is in my clipboard

@ Miguel; Senor, there are many relay tutorials available from the net... Adafruit, SparkFun.... and even the playground here. I have found that If I search Google I can get a whole lot of answers and I just pick the one that fits my situation best. I don't have to post the question here and try to deal with a great many people who don't fully understand the Question... ?Por Que?, Senor. The added advantage is that you can do it in your native tongue.

Bob

--> WA7EMS "The solution of every problem is another problem." -Johann Wolfgang von GoetheI do answer technical questions PM'd to me with whatever is in my clipboard

When the emitter of T2 is greater than two diode drops higher than ground, i.e around 1.4V, the emitter-base junction of T2 is reverse biased but the base-collector junction of T2 is forward biased by virtue of the 4K7 resistor connected to +5V. This biases T1 into saturation and its output drops to near ground.

The relay is 12 Volts and I have other of 9 volts. The transistror I use is a 2N222A and I do not know that I have emitter resistor to put

I've tried everything and no way to activate the relay coil . If is activated, then there is no way to disable

The program with leds works correctly.

Someone has the outline of a circuit to do this.

thank you very much

Miquel

Miguel, do what retrolefty said. Replace the 1K resistor with your relay coil. You must use a base resistor. If your relay doesn't have one internally, then put a reverse-biased diode (Cathode towards your positive voltage) across its coil.

@ PapaG, You are right I would Never thought of using a switched diode to do what can be done perfectly well with a single transistor. The circuit so intrigued me that I took a very careful look at it, simulated and then built a 2 transistor inverter. I apologize to You and Lefty and all involved for my fat mouthed insistance. The circuits posted by the OP are both inverters but one requires a current sink to change state and the other requires a current source to change state. Neither circuit as drawn will work very well as has been noted the first missing a resistor in the base and and the second one with a not so obvious fault. The second circuit will only work reliably if the input is held below about .5 volts, hang a Si diode from the input to ground cathode grounded and you have a thermometer... If you heat the diode gently.. 100 C, the switch turns off. Below that temperature with the emitter @ .65 Volts the switch is still on and if you heat both transistor and diode equally nothing happens the switch is still on. Not a very ideal circuit where a logic low is specified to be above the level that will cause the switch to turn off. In practice most of the time it will work But if there is even a small breadboard ground differential which is real easy to do it will fail and fail with temperature too.

Bob

--> WA7EMS "The solution of every problem is another problem." -Johann Wolfgang von GoetheI do answer technical questions PM'd to me with whatever is in my clipboard

@ PapaG, You are right I would Never thought of using a switched diode to do what can be done perfectly well with a single transistor. The circuit so intrigued me that I took a very careful look at it, simulated and then built a 2 transistor inverter. I apologize to You and Lefty and all involved for my fat mouthed insistance. The circuits posted by the OP are both inverters but one requires a current sink to change state and the other requires a current source to change state. Neither circuit as drawn will work very well as has been noted the first missing a resistor in the base and and the second one with a not so obvious fault. The second circuit will only work reliably if the input is held below about .5 volts, hang a Si diode from the input to ground cathode grounded and you have a thermometer... If you heat the diode gently.. 100 C, the switch turns off. Below that temperature with the emitter @ .65 Volts the switch is still on and if you heat both transistor and diode equally nothing happens the switch is still on. Not a very ideal circuit where a logic low is specified to be above the level that will cause the switch to turn off. In practice most of the time it will work But if there is even a small breadboard ground differential which is real easy to do it will fail and fail with temperature too.

Bob

I'm glad you were stimulated to look deeper into the circuit. The second circuit works better when integrated onto a piece of doped silicon and with the addition of a totem pole output stage. With the addition of multiple emitters on the first stage, it is the basis for all TTL logic.

If you replace the input transistor with a pair of back to back diodes, as you alluded, you have the classic DTL input stage.