Help me understanding how optocoupler works

Hi forums, I'm very get confused by understand of the optocoupler, i tough it works the same way as relay ( kinda ) but it's not i guess ?

So in regular relay, on output side, i can cut the flow no matter which side current i connected, either is + side or - side right ?

Now I'm trying to use optocoupler as switch, and now I'm struggling understand how optocoupler works.

When i connect the ground to the collector , and led ground to the emitter, it's just work fine

But when i switch the 5v to the collector, and the emitter to the positive led , the led doesn't turn on

( Assuming the optocoupler is already in on state )

Can someone explain me why this is happening? I'm i missing something?

And also i wanted to know in what voltage does optocoupler work ? I'm using as same as the picture below

Here's the connection

I'm sorry, i don't know how to draw a sketch, I'm trying my best
IMG_20221121_003635

About the optocoupler:

Please post a photo of a hand drawn schematic diagram showing your complete circuit. You need both a current limiting resistor and a load resistor, something similar to this:

Capture

By omitting the required current limiting resistor, the internal LED may have been destroyed.

The basic idea of an optocoupler is that the phototransistor current is approximately proportional to the intensity of the light produced by the internal LED. An optocoupler is not like a relay.

All I need is current limiting resistor, if I'm working on 12v to operating the opto, how many ohm do I need ?

If the LED is destroyed, the optocoupler is useless.

To determine the value of the current limiting resistor, first look up the maximum LED current in the manufacturer's data sheet. Then choose a resistor so that the LED current is less than that. There are tutorials on line.

All I need is current limiting resistor,

You also need a load resistor for the phototransistor.

What is the opto part number?

Thank you for the guidance, i will try again, and yeah maybe the optocoupler is destroyed, i will try with another

It's PC 817

The LED is galvanically isolated from the collector and emitter of the phototransistor.

post the data sheet or a link for help

Current limiting resistors are needed on both the LEDs, the one inside the Opto-coupler and the one being driven off of pin 3.

1 Like

But maybe not in the actual circuit that was never posted...

That is the circuit the OP added to his original post.

I've add the data sheet of the optocoupler on the post

Thank you, but in future please add updates in a new post. Often, changes to previous posts make the replies seem unhinged.

Thank you for the guidance, still new on the forum, will more details on first post next time

Anyway the led I'm working on is 5v LED, I've tried to directly connect the led to 5v and it works, but when i connect the led driven by optocoupler, it's doesn't turn on

Please post a schematic of your circuit. Right now, you are forcing people to guess a lot.

schematics-or-circuit-diagrams

A 5V LED may be 2 LED's in series with a constant current source built in. It will not run if the voltage goes much below 5V.
The opto coupler will have some voltage drop (especially if the led inside is not at max).
Also your opto coupler may not be suitable for power LED's. Do you have any specs on your 5V LED? Or a type nr.?

Still not useful information without a schematic.

Good tutorial on how to read/draw a schematic diagram.