transistor as a switch with the use of a microcontroller

Discussion in 'The Projects Forum' started by incubus, Jan 23, 2010.

  1. incubus

    Thread Starter New Member

    Nov 22, 2009
    hi guys,

    i have a transmitter circuit and a microcontroller.

    I'd like to switch this transmitter circuit on and off with the use of the microcontroller.


    they say that i should use a transistor that would act as a switch but i don't really have any idea about transistors and all the computations in the web are very complicated.

    where should i put the transistor?

    Can you guys help me? thanks in advance.
  2. retched

    AAC Fanatic!

    Dec 5, 2009
    About 1/3 way down, read transistor as switch.

    The way it operates:
    You have 3 pins. Your existing circuit (where you want a switch) would enter the collector pin and exit the emitter pin. The third pin, the base, will connect the collector and emitter when the base voltage hits a preset point. The point at which the transistor switches differs. Find the transistor that matches or fits your specs.

    The Wikipedia page I linked to has a schematic for a simple transistor-switched circuit.
  3. SgtWookie


    Jul 17, 2007
    You don't have your general location (like your country at least) in your profile, which makes it difficult to recommend parts.

    In the States, a 2N2222 is a very popular NPN switching transistor. A 2N2907 is (roughly) it's complement in a PNP transistor.

    If you are using a bjt (transitorized) version of the 555 timer, you are better off switching the ground side of the LEDs. Even under light load, the output of the 555 timer will not get much above Vcc-1.3v. So, you connect the current limiting resistors to Vcc, the LED anodes to the current limiting resistors, the LED cathodes to the transistors' collectors, and the emitters get connected to ground. The transistor's drive signal comes from the 555 output.

    You must limit the current through the base of the transistor using a resistor. When you use a transistor as a saturated switch, you supply 1/10 of the desired collector current through the base.
  4. lmartinez

    Active Member

    Mar 8, 2009
  5. incubus

    Thread Starter New Member

    Nov 22, 2009
    hi everyone.

    i did everything on the website and came up with this schematic diagram.


    the one inside the box is a 38KHZ IR TRANSMITTER and it is 100% working (meaning, my other receiver circuit can detect it.)

    but when i used the transistor as shown in the diagram above, my receiver can no longer detect the transmitters.

    the IR LEDS are still emitting IR light.

    i think the transistor 2N3904 AFFECTED THE TRANSMITTER'S FREQUENCY.

    What do you think is the problem?
  6. SgtWookie


    Jul 17, 2007
    Please turn the PINS layer off; it makes it hard to read the schematic.

    The 2N3904 is pretty limited as far as how much current it can sink. 100mA is about the maximum useful. However, you have a 3.3k resistor on the base, which is really limiting the current it can sink.

    Rule of thumb when using a transistor as a saturated switch is Ib = Ic/10. So, if you need 100mA of current through the collector (the Ic part), you need to put 10mA current into the base.

    If you are using 5v for Vdd/Vcc, then:
    Rbase = (Vcc-Vbe) / (Ic / 10)
    Vbe will be around 0.8v, so...
    Rbase = (5v-0.8v) / (100mA/10)
    Rbase = 4.2/10mA
    Rbase = 420 Ohms
    Consulting a table of standard resistors (located here: - bookmark that page)
    ... we find out that 420 Ohms is not a standard E24 value (the most common resistor values used are in the E24 decade) but 430 Ohms is. This is only a few percent over the actual value needed.

    Note that you must make certain that your I/O pin does is not required to source or sink more current than it is rated for; generally 20mA maximum. Double check your math before connecting stuff up, otherwise you might wind up with a burnt piece of plastic rubble instead of a working microcontroller.

    5v/430 Ohms = 11.63mA - that is a safe amount of current.

    Try it with the new resistor value. If that does not work, you will really need to change to a more robust transistor, like a PN/2N2222, and decrease the resistor to 270 Ohms (that's about the minimum "safe" limit.)
  7. russ_hensel

    Well-Known Member

    Jan 11, 2009
    Connecting LED's in parallel is also usually a no no, each shoul have its own current limiting resistor.
  8. Wendy


    Mar 24, 2008