0

I am trying to manipulate the GPIO pins using python. I have used many examples from the web. However, I noticed weird behavior of GPIO ports.

1) If I make a port high, it becomes high momentarily and then again it turns low.

2) If I initialize a port for output then it stays high regardless of the value we set.

Can anyone please help me with that? I am using RPi 2.

import RPi.GPIO as GPIO
from time import sleep
GPIO.setmode(GPIO.BOARD)
GPIO.setup(12, GPIO.OUT)
GPIO.output(12, GPIO.HIGH)
sleep(10)
GPIO.output(12, GPIO.LOW)
sleep(10)
GPIO.output(12, GPIO.HIGH)
sleep(10)
GPIO.output(12, GPIO.LOW)
sleep(10)
GPIO.cleanup()
5
  • 1
    Can you post the code you're using to switch your GPIO pins?
    – goobering
    Commented Sep 22, 2016 at 12:09
  • 1
    Are you connecting anything to the ports? Please show your circuit.
    – David
    Commented Sep 22, 2016 at 12:22
  • 1
    I am posting the code. Give me few minutes. Thanks a lot for your response. Commented Sep 22, 2016 at 13:00
  • It's difficult to fault that. Not much going on! Per David's comment above, is anything connected to the pins? There have been a lot of previous questions where things like cobbler boards have been connected back to front, leading to much confusion.
    – goobering
    Commented Sep 22, 2016 at 13:34
  • Have you tried any other libraries like gpio zero? This problem sounds strange though. Have you hooked an oscilloscope up? Commented Jan 15, 2017 at 16:49

1 Answer 1

-1

Instead of using GPIO. HIGH/Low try using 1 for high and 0 for low.

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.