4
$\begingroup$

I'm following this tutorial on how to control Raspberry Pi GPIO pins with Python scripts. Instead of connecting the test circuit (LED + resistor) between the ground and the GPIO pin however, they connect it between the +3v pin and GPIO (see section 4, last paragraph). The author says this is to have the current come from the 3v pin rather than the GPIO pin. However, from my limited understanding of electricity, the magnitude of the current through the GPIO pin should be the same regardless of how the polarity has been set, the only difference would be its direction.

Am I wrong about the current? Is it actually better to draw power from the 3v pin instead of the GPIO pin?

$\endgroup$
1
2
$\begingroup$

I think the reason is if the GPIO is used the micro is starved of power.

In the method described 3.3V is the power source. So the micro is not starved of power. If the 3.3V was provided by the GPIO pin, the micro is sourcing the power.

I am generally used to seeing a transistor used to switch on/off elements like a LED. Below is an example schematic.

LED Schematic

Further details can be found in The bipolar transistor article.

$\endgroup$
3
  • $\begingroup$ This makes sense. Do you mean that the transistor is used like a relay? $\endgroup$ – Carlton Feb 18 '16 at 18:17
  • 2
    $\begingroup$ Like this in figure 2 of the document. The signal generator is GPIO pin. Yes you could us a relay too but it might a little bit over kill in this situation $\endgroup$ – user1586 Feb 18 '16 at 18:19
  • 1
    $\begingroup$ That's a great resource for someone at my level. Thank you. $\endgroup$ – Carlton Feb 18 '16 at 18:35
1
$\begingroup$

Early TTL outputs (those typical of 74xx00 series logic gates) were capable of sinking (creating a current path to ground) more current than they could source (creating a current path to VCC). If you wanted a predictable current flow which you could set by your choice of external current limiting resistors then the output transistor path to ground did a better job.

As far as I know this is still true.

$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.