Transistor as a switch

Discussion in 'The Projects Forum' started by sportsfan27, Mar 14, 2009.

  1. sportsfan27

    Thread Starter Active Member

    Jan 29, 2009
    43
    0
    Whats the best way to turn a transistor functioning as a switch on and off?
     
  2. thatoneguy

    AAC Fanatic!

    Feb 19, 2009
    6,357
    718
    NPN or PNP?

    What are the voltages, and load?
     
  3. sportsfan27

    Thread Starter Active Member

    Jan 29, 2009
    43
    0
    all NPN, voltages range from 10V-250V
     
  4. SgtWookie

    Expert

    Jul 17, 2007
    22,182
    1,728
    Can you more fully describe what it is that you're trying to accomplish?
     
  5. Wendy

    Moderator

    Mar 24, 2008
    20,764
    2,534
    As a general (very general, lots of exceptions) rule of thumb the emitter is grounded, so the base to emitter current (which turns the transistor on/off) doesn't get involved. The collector/emitter turns on/off, but you have to be carefull it doesn't enter its linear region.
     
  6. sportsfan27

    Thread Starter Active Member

    Jan 29, 2009
    43
    0
    What I'd like to happen is have a microcontroller turn on the transistors every couple of seconds. The transistors will act as a switch for several LEDs.
     
  7. mik3

    Senior Member

    Feb 4, 2008
    4,846
    63
    Use NPN transistors, with their emitter at ground, a resistor (about 1K) between the base and the microcontroller and your load between the collector and Vcc.
     
  8. sportsfan27

    Thread Starter Active Member

    Jan 29, 2009
    43
    0
    That's exactly the circuit I have. I don't think I was clear enough, though; my question should have been, how do I program the microcontroller to turn the transistor on and off?
     
  9. mik3

    Senior Member

    Feb 4, 2008
    4,846
    63
    Which microcontroller?
    At what programming language?
     
  10. SgtWookie

    Expert

    Jul 17, 2007
    22,182
    1,728
    Set the pins you're using to output.

    Set the pin to a logic high (1) to turn the transistor on.
    Waste some time in a delay loop.
    Set the pin to a logic low (0) to turn the transistor off.
    Waste some time in a delay loop.
    Repeat
     
  11. mik3

    Senior Member

    Feb 4, 2008
    4,846
    63
    I quite disagree with Sgt to waist time in a loop. You can set the particular output to 1, make some other calculations with the uC and then set the output to 0 if desired.
     
  12. hgmjr

    Moderator

    Jan 28, 2005
    9,030
    214
    Perhaps you would be interested in reading up on the use of a transistor as a switch. The link I have provided takes you to the section on transistors operated as switches. It will provide with some background info so that you will better appreciate the other comments your post has garnered.

    hgmjr
     
  13. thatoneguy

    AAC Fanatic!

    Feb 19, 2009
    6,357
    718
    While very true, what should the uC be calculating if it's entire function in life is to blink LEDs on and off?

    Getting philosophical, I suppose the uC may be more eager to blink the LED if he also gets to calculate 1000 digits of pi, followed by 1000 digits of e, but in the end, it is all wasting cycles, since the results can't be displayed. Unless the silicological portion of the "id" is somehow boosted, causing the now happy and confident uC to use less power.
     
  14. SgtWookie

    Expert

    Jul 17, 2007
    22,182
    1,728
    Mik3,
    My suggestion was IAW the "KISS" principle. ;)

    Sure, I could've suggested that our OP utilize an interrupt when timer0 or timer1 overflowed and increment a counter, disabling and re-enabling the interrupt during the service routine, but for this simple exercise such would be rather bewildering for a "n00b".

    As it is, just coding delay loops in assembler can be intimidating.
     
  15. mik3

    Senior Member

    Feb 4, 2008
    4,846
    63
    I have made just a suggestion, don't kill me ;) :p
     
  16. thatoneguy

    AAC Fanatic!

    Feb 19, 2009
    6,357
    718
    I can't get Marvin the Paranoid Android out of my head since your post. :eek:
     
  17. SgtWookie

    Expert

    Jul 17, 2007
    22,182
    1,728
    Well then, we'll just have to squash your head. :eek: :D
     
  18. mik3

    Senior Member

    Feb 4, 2008
    4,846
    63
    Who is he?
     
  19. hgmjr

    Moderator

    Jan 28, 2005
    9,030
    214
    You have not read Douglas Adams I see.

    hgmjr
     
Loading...