Other than this, my only doubt now is about the setup code, which I found in the link you posted I think:
Code:
digitalWrite(relay_pin, 1);
pinMode(relay_pin, OUTPUT);Why the internal pullup? Is it needed for this module?
That's just a function of how the relay boards opto input is wired to the arduino. It requires a output pin and set LOW to turn on the relay, and a HIGH output to turn it off. Putting this code in setup function and making the output pin HIGH early in the sketch is just a way to insure the relay doesn't 'glitch' on when first being powered up, especially if you are using an external DC voltage source to power the relay coils. Many begineers using these boards have a mental block about a digital output = high means turn off the relay channel and output = low means turn on the relay channel, but it's only a user mental limitation, not a coding problem. ![]()