Using a triac (like BTA12 ot BTA08)

Both circuits are complete nonsense, but for different reasons.

In the second, the opto-triac connects gate to MT1. There is no way to develop any voltage to actually fire the Triac.

Both circuits show a PNP transistor with emitter to 12 V and the base through a 2k2 resistor to the Arduino control pin. Since the Arduino control pin switches between 5 V and ground, the resistor sees either 7 V or 12 V and the transistor is always turned on.

If the MOC requires only 10 mA to trigger (as suggested by the 1k2 resistor "R1"), then driving it directly from an Arduino pin with a 330 Ohm resistor will work just fine. There is absolutely no need for the 12 V supply or transistor. :roll_eyes:

Well, OK, a 220 Ohm resistor. :grin: