This circuit may work, but I would put an amplifier on the receiving end. This could reach almost 10 meter on a good design.

As for the translation, why not make it from scratch? You will learn something in the process.

It is more than sure that the translation of a C program will have difficulties.

Ioannis