I am trying to connect a circuit like this.

GPIO25 -- LED -- GPIO24

and I try to turn the LED on by exporting both GPIO and setting 0 in GPIO24, 1 in GPIO25.

but it fails.

Is there any way to program a GPIO, for example like GPIO24 in Raspberry Pi as a GND?

  • 1
    Some factors here: 1-are you sure both pins are set as OUTPUT? Please check the voltages on both of them and show us the results. 2-the sinking capacity of an output might be different from the sourcing capacity. Make sure both pins can provide your led current, considering the resistance.
    – Marco Poli
    Jun 3, 2014 at 13:51
  • 1
    here are two group of pins. First group contains power supply pins (+5V, +3.3V and GND). You take power supply for your boards/elements from these pins. The other group contains data pins (you can call them also control pins or signals) and its members are all remaining GPIO connector pins. You should avoid using them for supplying your boards/circuits.
    – bouqbouq
    Jun 3, 2014 at 15:24
  • 1
    Your setups should work just fine. Setting it to output and low is pretty much identical to GND. So either you code is incorrect, or your wiring. Since you've shown neither of those, we can only guess. PS a resistor is a bad thing to add when connecting leds. Blue and white might work fine when connecting to 3.3V but other colors will draw to much current and destroy themselves and might take the Pi with it.
    – Gerben
    Jun 3, 2014 at 17:59
  • Thank you all for your comments. I finally figure out the reason by testing the voltages. The problem is I was not really setting the value of GPIO24 to 0. I unexported it without changing the value, so it seems as long as the value remains unchanged, unexport has no effect on the voltage.
    – Znatz
    Jun 4, 2014 at 2:03

1 Answer 1


You "can" do do it that way, but it would be easier to use ground. Setting it up the way you describe will require you to setup one pin high and one pin low. It's like having two light switches next to each other to control one light. You can do it that way but it's more complicated. You also want to have a resistor. A LED is a diode, and allows electrons to flow easily in one direction. Without a resistor in the circuit you will create a short that will draw too much current and might damage something. I have seen people recommending 330 Ohm resistors for one led projects. So add a resistor for safety, and then you set GPIO25 to output mode using:

gpio -g mode 25 out

Then set the pin to high(3.3v)

gpio -g write 25 1

As long as you have the led the right way around this will work. If you want to connect the other end to another gpio pin(instead of the GND pin right next to BCM_GPIO pin 25), you can just write 0 to that pin. Here is a picture that might help. enter image description here

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

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