2

When I initialise the GPIO by

import RPi.GPIO as GPIO
GPIO.setmode(GPIO.BCM)
GPIO.setup(24, GPIO.OUT, initial = GPIO.HIGH)

and I do gpio readall in command line, I can see that value of pin 24 is 1.

But if I then try to change the value from Python using

GPIO.output(24, GPIO.LOW)

then it doesn't work.

Also if I connect LED to ground and then to 3V3 pin, it lights up, but when I connect it to ground and pin 24 when turned on, it doesn't. Where might be my problem?

1
  • "Also if I connect LED to ground and then to 3v3 pin," You need a resistor in between for safety! I can assure you that if your GPIO pin is actually high, the Pi is working, the LED is working and you got the polarity of the LED right, it will light up (longest leg connected to the positive terminal/GPIO pin while high). gpio readall might conflict with RPi.GPIO - do the reading via python and RPi.GPIO instead.
    – jDo
    Commented Apr 6, 2016 at 22:53

2 Answers 2

3

Try to use GPIO.output(24, False) instead of your last line to change the output from high to low, another possible issue may be power draw because the arm chip will supply much less power than the 3v3 rail.

2
  • Okay, thanks, that works for the switching, I don't understand why there is such an inconsistency but whatever. So to make it work I should use transistor controled from the pin 24 which would then switch power from the 3v3 directly right?
    – m3div0
    Commented Apr 6, 2016 at 21:52
  • Yes, please look into something like an npn or pnp transistor Commented Apr 6, 2016 at 21:54
0

In your script you are using BMC and setting 24 high. Since you are using BMC you will not be switching pin 24. BMC 24 is actually pin 18. To connect your LED put a resistor (330 ohms should do) in series with it then connect between pin 18 and ground. Follow this link to see BMC and actual pin layout

1
  • I know which pins are which in BMC, actualy the problem was in using GPIO.LOW instead of False
    – m3div0
    Commented Apr 6, 2016 at 23:14

Your Answer

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

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