I have an Arduino Mega and a 4-channel relay module.

This is the relay module.

When the Arduino digital output is LOW, the relay is energized. When the Arduino output is HIGH, the relay coil is de-energized.

How can I fix this?

3 Answers 3


That's how they're designed to work energized is LOW de-energized is HIGH you just need to take this into account when writing your Arduino code

  • 1
    Indeed, while not particularly relevant with an ATmega, historically low-side outputs have been stronger than high-side ones, so when driving an LED (in this case probably one inside an optocoupler on the relay board) it has been conventional to use the I/O pin to drive the LED cathode, while wiring the Anode to the supply. (It doesn't really matter which side the current limit resistor goes on, since the same current flows in the entirety of the path). Apr 21, 2016 at 15:40

If you read the documentation or watch/read any tutorials on the mechanical relay you are using you will learn that LOW is active and HIGH is inactive for these devices. There is no way to change that behavior, that is how they are built. (Well, you can, but it's not worth the effort)

This design is intentional to prevent relay activation on power-up or system reset. And be sure to put this code in your setup routine to ensure proper system initialization.

digitalWrite(Relay, HIGH);
pinMode(Relay, OUTPUT);

Where Relay is the pin variable you defined for your relay.

Just code your routine using LOW to activate the relay when necessary.

Try this tutorial 4 channel relay tutorial

  • I would first set it to output, and then set it high? Not sure if it makes a difference though.
    – Paul
    Apr 22, 2016 at 7:21

Hiii brother, yes all relays has this problem exept keystudio relay modules, you can fix it about using a trasintor npn 2a2222 and connect gnd to collector, pin x to base and relay pin to emetor,

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.