Getting two Arduinos to talk to each other via an optocoupler
In order to synchronize two deices transmitting any information you need a CLK signal. CLK stands for clock so basically you send a 1 each time you want to send a bit of data. But in order to do so you need one more wire and a CLK generator (usually the transmitter). 
It is described very well in the video of Ben Eater about Reliable data transmission. So I recommend you watching the video since Ben covers a lot of important topics on data transmission and shows a arduino example of how to transmit and receive data properly.