Here’s an easy way to transfer data with an infrared LED and an infrared remote control demodulator. The example uses an Arduino, but the technique will work with any microcontroller.
The transmitting microcontroller powers an IR LED from a pin configured as a 38KHz pulse-width modulator. Another pin configured as a 2400bps UART switches the IR LED ground pin on and off. This converts the standard UART output into a train of rapidly-blinking light pulses.
The receiver is an IR remote control demodulator connected to a 2400bps UART input pin. The demodulator is specially tuned to detect IR light pulses at 38KHz. It converts the transmission back into a 2400bps UART bitstream.
How would you use a line of sight data link?