Do not copy any schematics found on arduino forums if you don’t understand them. Most of them are published by people who don’t know what they are doing. They might work just by chance!
Proof: when I started electronics, I just did this. I copied the 4N28 schematics that was circulating on the arduino forum. I actually used this on the original Shruti-1. Well, let me tell you, this circuit is pure crap and did not work with a bunch of MIDI devices. You might have more luck with a CNY17-1, but I do not recommend “passive” optocouplers like the 4Nxx or CNY. The right way to do it is to use an “active” optocoupler, capable of amplification, like the 6N137 or 6N138. Open the lid of any recent commercial product and it’s almost always one of these two guys.
The 6N137 is the one that gives the sharpest edges – even with a 10k pull-up. The 6N138 has soft positive edges, you’ll have to use a very low pull-up resistor (220). Both work with the appropriate choice of pull-up. I’m not sure why people prefer the 6N138 – maybe there are situations in which people want to avoid very hard edges running on their PCBs… Using a scope to monitor the signal edges helps a lot! I’ve found that the 6N138 are more sensitive when being manipulated – I’ve destroyed a few. So I’m a 6N137 guy.