Relay board to powered on when booting.

Hey guys,

I'm using a relay board to control some appliances. The relay is powered on when it receives a 5V signal from a digital pin.

Using a simple "if" statement in the loop I can power the relay on and off with a pin button. It works fine but,

my problem is that the digital pin is in the LOW state when the Arduino is powered up. I however need it to be in the HIGH state when powered on so that all relays are ON should power restore after a power outage.

When I code digitalWrite(A1,HIGH); into the setup I lose the ability to switch the relay off.

Any ideas? :slight_smile:

Set the pinMode to OUTPUT.

After reset or power cycling, the IO pins are INPUTs until your sketch takes over to make them OUTPUTs.
This could be a few seconds depending on the bootloader, and our sketch.
Add a pullup resistor to the pin. 10K might do, depends on the load. That will hold the pin High.

Already got it as OUTPUT but will give the resistor a shot.

Thanks guys.