My Pi is acting in a way i'm not expecting. When I set the value of a pin to 0 like

'echo "0" > /sys/class/gpio/gpio18/value'
or when using python
GPIO.output(18, GPIO.LOW)

it has the effect of turning on the LED I have wired up. Also when I set the value to 1 it turns the LED off.

Is my Pi broken or am I missing something?

  • 2
    How is the LED connected?
    – Craig
    Aug 20 '13 at 21:29
  • it is connected to the 3.3v power with a 270 ohm resistor followed by the LED then a connection back to GPIO18 pin
    – Robert
    Aug 21 '13 at 5:33

that's correct behaviour, if your LED is connected to the +5V rail with a resistor:

GPIO resistor LED     +5V

you may try to connect it to the GND (ground) if you like to reverse the ON/OFF depending on the value you set to a GPIO pin.

  • 2
    So if I understand correctly by setting the pin to zero it has the effect of being a grounding pin and completing the circuit, is that the case?
    – Robert
    Aug 21 '13 at 5:42
  • @Robert : you're correct.
    – lenik
    Aug 21 '13 at 8:46

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.