Hello!
I am looking to better understand how this works?
I was going over the datasheet for this Opotcoupler Board: ELEGOO 4 Channel DC 5V Relay Module with Optocoupler Compatible with Arduino UNO R3 MEGA 2560 DSP ARM PIC AVR STM32
I noticed the schematic shows voltage going from VCC to the LED and then to the "in" pin. This leads me to think (probably incorrectly) that the pin is "active" if it is connected to ground. The example given on the datasheet has the "in" pins connected directly to digital pin on the Ardunio. When the pin is set high, the relay is active. Can you explain how this works? It seems to me that I would be providing 5 volts via the Vcc and "in" pins of the optocoupler.
Correct. If a digital pin is used to control the relay via the optocoupler, the relay will be activated if the digital pin is set to LOW.
There is a current limiting resistor and indicator LED in series with the optocoupler LED, so it is safe to connect a digital pin directly to the relay module.
The input side, which is usually an opto-isolated LED.
The control side, which includes the relay coil.
The output contacts, which switch your external device.
When the input LED turns on, it activates the relay coil, which closes or opens the output contacts. Whether the relay activates on a HIGH or LOW signal depends on how the input LED is wired in your module.
The coil itself needs power to operate, often 12V from an external source, though some modules can use 5V from the Arduino (not recommended if the relay draws significant current). Because the relay is triggered optically, it provides isolation between the control signal (Arduino) and the high-power side. The output contacts are also isolated and usually configured as a SPDT (Single Pole Double Throw) switch.