i'm totally new with optocoupler , so i need to use it nowadays with a microcontroller project to get a signal from the microcontroller and then control 12V contactor of a relay
First you need to check the datasheet of the PC817 to see if it can drive said relay sometimes relay coils can take 100 mA+. Secondly! you need a resistor (@ 470 ohm) on RA pin.