-3

I wanted to know if anyone knows if I can use a transistor as an on/off switch that is controlled by a GPIO pin? I am sorry that I have to right this but this needs to be the right length so that I can post it.

Nicholas
  • 37
  • 1
  • 10
  • 1
    Hi Nicholas, there's a Stack Exchange site specifically for RPi [here](http://raspberrypi.stackexchange.com/), you will probably find better answers there. This is probably off-topic for SO since it's not specifically about programming. But I think the short answer to your question is yes ([this](http://elinux.org/RPi_GPIO_Interface_Circuits#Using_an_NPN_transistor) may be helpful?) – user812786 Mar 08 '16 at 17:21
  • It rather depends on what you mean by "on/off" switch. You can certainly drive the gate/base and control _some_ transistors directly from an output pin. To close a circuit between two arbitrary points you'll need a relay though, and likely a transistor to help drive its coil. Can you elaborate on the circuit you have in mind? – doynax Mar 08 '16 at 17:24
  • 2
    I'm voting to close this question as off-topic because it do not belongs to SO – Saic Siquot Mar 08 '16 at 17:31
  • GPIO pin into the centre transistor pin xbox controller button into transistor, transistor out to xbox button and gpio ground. BTW i'm new to transistors – Nicholas Mar 08 '16 at 17:32

1 Answers1

2

Yes

Like below (not the only way).

GPIO high = switch on

GPIO low = switch off

enter image description here

Van Tr
  • 5,889
  • 2
  • 20
  • 44
  • Does it matter if the "Loads" voltage is only 2.2v – Nicholas Mar 08 '16 at 17:40
  • huhm, seem that you need to read some basic electronics first. – Van Tr Mar 08 '16 at 17:55
  • @IlDivinCodino No pulldown/up? "GPIO low = switch off" won't necessarily be true without it. – jDo Mar 08 '16 at 18:11
  • @jDo do you see there is a Load ? – Van Tr Mar 08 '16 at 18:47
  • Well i want to control a xbox controller but to get to the coding part i need to wire up the controller first so i'm new at this – Nicholas Mar 08 '16 at 18:56
  • @IlDivinCodino Sure, so? Are you saying that having the negative terminal of the load connected to the collector will eliminate the need for base resistors other than to/from the GPIO pin? – jDo Mar 08 '16 at 19:25
  • 1
    @Nicholas Yes, you could probably use a transistor for this (but a logic level MOSFET might be better) and yes, the load voltage also matters. Often, you'll find that you need to have a certain difference/bias between load and base voltages to turn on/off cleanly. If you go with the circuit above, I suggest you add a pulldown/pullup resistor like it's done here https://i.stack.imgur.com/j6tOm.png Anyway, there's a lot to be said and read but this isn't the right forum. You should probably pose your question in the raspi/electrical engineering/arduino sections instead. Cool project though :) – jDo Mar 08 '16 at 20:57
  • @jDo My answer is just to show him it's possible with a simple example. You had a wonderful comment. – Van Tr Mar 09 '16 at 05:40