In my circuit a have a 2 switches that connects to a logical gate and the output of gate will go to a relay but after the logic gate the voltage got lower to mili voltage and not enough voltage for the relay to work, they say that I must use capacitor but it only last for a second and I want my relay to work in indefinitely by the result of the two switches of the logic gate. Anyone have an idea or hint to solve my problem?
4081 logic gate, according to its datasheet, can maximally supply 10 mA current at its output. If you connect relay with low active resistance, voltage will significantly sink and current will increase up to chip burnout if applied for prolonged period of time.
I propose you to change circuit adding transistor able supplying required current between logic gate and relay.
Here's a few ways of doing the same thing.
Circuit 1 - is a simple AND gate made from two switches in series. The LED is driven directly with R1 to limit the LED current.
Circuit 2 - replace the LED/resistor with a relay coil. Note the reverse diode across the coil which prevents the back emf spike from damaging the switches when you turn OFF. The switch contacts of the relay now control the LED.
Circuit 3 - Now we've added the 2 input AND gate. Note R1 and R4 (47k) are PULL DOWN resistors to ensure the inputs stay at 0V when the switches are open. This resistor value is not critical and could vary from 1k0 to 1M0. The output of the gate is capable of supplying enough current to light an LED. Again the 1k0 resistor is there to limit the maximum LED current.
Circuit 4 - If we need more current output we can add a transistor, in this case a BJT but we could use an N channel MOSFET (not shown) if we needed to switch a much higher current e.g. a motor or a solenoid. The transistor is just used to switch the LED.
Circuit 5 - The transistor is being used to switch the relay coil. Note we keep the reverse connected diode. In this case it protects the transistor. R3 value has been lowered to allow for more current through the transistor taken by a relay coil.
Uhm , does this circuit:
not achieve the same thing as what you intended to achieve ?
So you don't need the AND gate
You don't need the relay.
You do want to add a 470 ohm resistor so you will not destroy your LED by applying 9V to it (LEDs generally do not like that).
If this is not what you wanted then specify more clearly what you wanted in the first place.