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?

  • "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 Apr 6 '16 at 22:53
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.

  • 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? – david Apr 6 '16 at 21:52
  • Yes, please look into something like an npn or pnp transistor – Mohammad Ali Apr 6 '16 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

  • I know which pins are which in BMC, actualy the problem was in using GPIO.LOW instead of False – david Apr 6 '16 at 23:14

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.