IR-communication

You need a third pin to use half duplex

No you don't.
You just shut down the sending LED when you are expecting to receive.

Please read the sticky topic read this before posting to see how to post code correctly.