No current through AC optocoupler

You've got three problems.

1: no current limit on the MOC3021 LED. With 5V there the LED inside the MOC3021 will not last long, so add 220 ohms in series with the input.

2: not enough voltage on the output. The output is is a phototriac which has a forwards voltage drop of 1 to 1.5V - to light the blue LED you want 3V or so and a resistor to limit current, 9V with a 470 ohm resistor in series would be a good starting point.

3: the output is a triac: once triggered on, it will continue to conduct until something else stops the current - using an AC supply to power the output side circuit would help here.


You have two small problems:

No resistor in series with the opto led. So the current is not limited, and will burn the opto if you try in real life

A voltage source too low to light a blue LED. Such LED typically require about 3 to 3.5V. You have 1.5V on this side which is far from sufficient. With a 100 ohm resistor, something like 4.5V would give something like 10-15mA.


In addition to what dim commented, Your voltage source BAT2 has the wrong polarity. The LED D2 is now in reverse bias by the voltage source BAT2. You could change polarity of either BAT2 of LED D2 in order to let current flow throug the LED when MOC3021 is enabled by the primary side.