Should work fine. Pretty straight forward, most 'standard' optoisolators use an internal LED for it's input so it can interface with a Arduino PWM digital output using just a series current limiting resistor set to 10 ma or so. The output of a optoisolator come in different flavors, most are just an NPN emitter and collector output so just make sure the max voltage and current capacity is compatible with what your driving. Some isolators have a TTL output and others have triac outputs for switching AC loads, etc. As far as switching speeds they do come in different capabilities but the standard ones should be more then fast enough for the standard Arduino PWM switching speed.
I would want the opto to be the same outputs as what the arduino can handle. This is just for protection incase someone connects up the outputs wrong on my product.
Well in that case a standard npn output would work fine, the emitter would connect to the #2's device ground, the collector would wire to a pull up resistor to #2's device +5vdc and a wire from the collector would route to a #2 devices digital input pin.
Lefty
Well that example is a darlington pair output and using a emitter resistor to output a signal but yes that configuration should work OK depending of the value of the voltage applied to the collector lead. Too high a voltage would draw quite a bit of current through the 100 ohm resistor. A lot depends on if you need a high or low value when activated. A collector resistor and collector take off would give you inactive high and active low output, while your example would give the opposite states. So kind of depends on what you are driving and what it needs.
Yes, that is the most common way I've seen used. You can raise the value of the collector resistor to say 500ohms to limit the collector current to 10ma or so as there is no reason to draw more.
While we tell people over and over to connect the grounds together, in the case of an opto isolator you don't want to connect them together or you bridge the isolation and negate the point of having it.
Good reminder and of course the same applies to the +5vdc, it must also not be wired together between the two system or the isolation is also defeated.