I have a raspberry pi connected to a Sainsmart 4-channel relay, where each relay is activated by a LOW signal.
When I set a GPIO pin to output, it defaults to LOW, which of course activates the relay for a split second before I can set it to HIGH. Is there any way to set the default output state before setting a pin to output mode?
Here is a very simplified version of my code:
import RPi.GPIO as GPIO
#pin is now outputting LOW by default
As you can see above, there is a split second between setting the pin to OUT and setting it to HIGH. During that time the pin is outputting LOW, which is the default state (If I try to set it HIGH before setting it to OUT, I get an error for trying to set the state of an input pin).
Having the pin output LOW even for a split second screws with what I'm trying to achieve. So basically all I want to do is have the pin default to HIGH when I set it to OUT.