Take the 2-minute tour ×
Raspberry Pi Stack Exchange is a question and answer site for users and developers of hardware and software for Raspberry Pi. It's 100% free, no registration required.

I have an LED connected to a GPIO pin and am using RPi.GPIO to control it. When setting up the GPIO pin, the LED blinks on ever so slightly when being initialized, which I don't want.

import RPi.GPIO as GPIO
GPIO.setmode(GPIO.BOARD)
GPIO.setup(22, GPIO.OUT)
GPIO.output(22, False)

setMode seems to briefly turn on the LED. Is there a way to prevent this? Is there a GPIO.setup(22, GPIO.OUT, default=False)?

share|improve this question
    
What happens if you try to set the level before you make it an output? You could also examine the kernel source and see if there is a way to change the behavior. –  Chris Stratton Nov 29 '12 at 21:49
    
if i do that it says I have to configure the pin before setting the level... –  Scoop Nov 29 '12 at 23:34
    
That's usually not a requirement at the hardware level (though the rp gpios are somewhat atypical) so it might be worth looking through the driver source and seeing if you can change things. –  Chris Stratton Nov 29 '12 at 23:37
    
Here is the exact error when I do thatL RPi.GPIO.WrongDirectionException: The GPIO channel has not been set up or is set up in the wrong direction –  Scoop Nov 29 '12 at 23:43
2  
Are you calling the GPIO.cleanup() method at the end of your program? Without it you might find you get odd results when the program is run multiple times as the GPIO will be left in the state it was when the program ended. –  Martin O'Hanlon Dec 3 '12 at 15:37
show 5 more comments

1 Answer

This issue was resolved in the comments, as per this comment on the original post.

This is simply a place-holder post until the OP creates a self-answer.

share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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