user31105: I have made a very basic test circuit for the opto coupler H11L1 ('similar'datasheet: http://www.datasheet4u.com/datasheet/H/1/1/H11L1_MotorolaInc.pdf.html))
I use the test circuit:

simulate this circuit – Schematic created using CircuitLab

The LED and 470 ohm resistor is only for testing.
U1 is the Arduino (software serial pin 9/11) and U2 is the H11L1.
The LED is flashing similar to the RX led on the Arduino.
Also I tested before in an even simpler circuit that the signals from the H11L1 pass through pin 4 (although inverted, which seems to be normal).
However, I don't receive any data in the Arduino (I tried different Arduinos, different speeds, different H11L1).
The data I receive from the (hardware) serial/debug terminal:
0
0
0
0

etc.
My sketch:
#include <SoftwareSerial.h>

SoftwareSerial mySerial(9, 11); // RX, TX

void setup()
{
    Serial.begin(9600);
    mySerial.begin(300);
}

void loop()
{
    mySerial.write('A');
    while (mySerial.available())
    {
        Serial.println(mySerial.read());
    }

    delay(100);
}

How can I get the correct signal? (meaning 'A' are printed instead of 0's?
Update
New sketch (not having the duplex problem):
#include <SoftwareSerial.h>

SoftwareSerial mySerial(12, 13); // RX, TX

void setup()
{

  Serial.begin(115200);
  mySerial.begin(115200);
}

void loop()
{
  Serial.print("Write: A ");
  mySerial.write('A');

  while (mySerial.available())
  {
    Serial.print((int) mySerial.read());
  }

  Serial.println("");

  delay(100);
}

Output:
Write: A
Write: A
Write: A
Write: A

etc.
Update
Problem solved: I put it in an answer for clearity.

user30198: Rule of thumb: never use SoftwareSerial (unless you have to, and even then you should avoid it).
The SoftwareSerial works better with higher baudrates. The lower the baudrate, the more trouble you get. Unless you aim for a high baudrate of 115200, then SoftwareSerial can cause troubles again. Remember that using SoftwareSerial means that there is not much else you can do in your sketch.
When SoftwareSerial is used with a very low baudrate of 300, then it could even disturb the receiving of data of other hardware serial ports. Because SoftwareSerial disables interrupts during transmitting and receiving, the lower the baudrate, the longer the interrupts will be disabled.
The SoftwareSerial can not transmit and receive at the same time, and that is what you are doing.
A Arduino Leonardo, Micro, or Arduino Mega 2560 board have unused hardware serial port(s). Use one of those to do tests with a serial port.
As soon as you start using SoftwareSerial for a test, you are actually testing the SoftwareSerial itself.
There is an alternative, the AltSoftSerial Library. it can receive and transmit at the same time. Use a baudrate that is not too high, 9600 baud should be fine.

user13749: 
simulate this circuit – Schematic created using CircuitLab
I'm not sure I can help much with the MIDI problem but I can help with the schematic. I've reorganised it for clarity. Since the opto-isolator has an open-collector output any loads it is driving should be connected to supply + rather than common.

31105: <p>I have made a very basic test circuit for the opto coupler H11L1 ('similar'datasheet: <a href="http://www.datasheet4u.com/datasheet/H/1/1/H11L1_MotorolaInc.pdf.html" rel="nofollow noreferrer">http://www.datasheet4u.com/datasheet/H/1/1/H11L1_MotorolaInc.pdf.html</a>))</p>

<p>I use the test circuit:</p>



<p><img src="https://i.stack.imgur.com/YeztS.png" alt="schematic"></p>



<p><sup><a href="/plugins/schematics?image=http%3a%2f%2fi.stack.imgur.com%2fYeztS.png">simulate this circuit</a> &ndash; Schematic created using <a href="https://www.circuitlab.com/" rel="nofollow">CircuitLab</a></sup></p>

<p><a href="https://i.stack.imgur.com/z0218.jpg" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/z0218.jpg" alt="Circuit"></a></p>

<p>The LED and 470 ohm resistor is only for testing.
U1 is the Arduino (software serial pin 9/11) and U2 is the H11L1.</p>

<p>The LED is flashing similar to the RX led on the Arduino.</p>

<p>Also I tested before in an even simpler circuit that the signals from the H11L1 pass through pin 4 (although inverted, which seems to be normal).</p>

<p>However, I don't receive any data in the Arduino (I tried different Arduinos, different speeds, different H11L1).</p>

<p>The data I receive from the (hardware) serial/debug terminal:</p>

<pre><code>0
0
0
0
</code></pre>

<p>etc.</p>

<p>My sketch:</p>

<pre><code>#include &lt;SoftwareSerial.h&gt;

SoftwareSerial mySerial(9, 11); // RX, TX

void setup()
{
    Serial.begin(9600);
    mySerial.begin(300);
}

void loop()
{
    mySerial.write('A');
    while (mySerial.available())
    {
        Serial.println(mySerial.read());
    }

    delay(100);
}
</code></pre>

<p>How can I get the correct signal? (meaning 'A' are printed instead of 0's?</p>

<h1>Update</h1>

<p>New sketch (not having the duplex problem):</p>

<pre><code>#include &lt;SoftwareSerial.h&gt;

SoftwareSerial mySerial(12, 13); // RX, TX

void setup()
{

  Serial.begin(115200);
  mySerial.begin(115200);
}

void loop()
{
  Serial.print("Write: A ");
  mySerial.write('A');

  while (mySerial.available())
  {
    Serial.print((int) mySerial.read());
  }

  Serial.println("");

  delay(100);
}
</code></pre>

<p>Output:</p>

<pre><code>Write: A
Write: A
Write: A
Write: A
</code></pre>

<p>etc.</p>

<h1>Update</h1>

<p>Problem solved: I put it in an answer for clearity.</p>
 30198: <p>Rule of thumb: never use SoftwareSerial (unless you have to, and even then you should avoid it).</p>

<p>The SoftwareSerial works better with higher baudrates. The lower the baudrate, the more trouble you get. Unless you aim for a high baudrate of 115200, then SoftwareSerial can cause troubles again. Remember that using SoftwareSerial means that there is not much else you can do in your sketch.</p>

<p>When SoftwareSerial is used with a very low baudrate of 300, then it could even disturb the receiving of data of other hardware serial ports. Because SoftwareSerial disables interrupts during transmitting and receiving, the lower the baudrate, the longer the interrupts will be disabled.</p>

<p><strong>The SoftwareSerial can not transmit and receive at the same time, and that is what you are doing.</strong></p>

<p>A Arduino Leonardo, Micro, or Arduino Mega 2560 board have unused hardware serial port(s). Use one of those to do tests with a serial port.
As soon as you start using SoftwareSerial for a test, you are actually testing the SoftwareSerial itself.</p>

<p>There is an alternative, the <a href="https://www.pjrc.com/teensy/td_libs_AltSoftSerial.html" rel="nofollow noreferrer">AltSoftSerial Library</a>. it can receive and transmit at the same time. Use a baudrate that is not too high, 9600 baud should be fine.</p>
 13749: 

<p><img src="https://i.stack.imgur.com/c3ph1.png" alt="schematic"></p>



<p><sup><a href="/plugins/schematics?image=http%3a%2f%2fi.stack.imgur.com%2fc3ph1.png">simulate this circuit</a> &ndash; Schematic created using <a href="https://www.circuitlab.com/" rel="nofollow">CircuitLab</a></sup></p>

<p>I'm not sure I can help much with the MIDI problem but I can help with the schematic. I've reorganised it for clarity. Since the opto-isolator has an open-collector output any loads it is driving should be connected to supply + rather than common.</p>
