How to modulate a LED to send data and recieve with a photodiode
I think you should start with maybe 100KHz before trying to push the envelope all the way to 1MHz. As you increase the pulse frequency, you'll run into a 'brick wall' at the limit of the LED's diode switching &amp; light emission pulsing frequency.

While there are super-fast diodes/lasers used for fibre transmission; not all LEDs will function at MHz speeds.

As for the actual modulation of the light; you can choose between AM, FM, OOK, or PWM for encoding data into your pulses. While I could write several paragraphs on using each in this instance, I don't think I would be doing much better than the respective Wikipedia articles, so I'll just refer you to them here.

Once you've decided on your baseband pulse frequency &amp; your modulation method, your MCU on the sending unit can directly drive a transistor to operate the sending LED.

On the receiving end, however, you'll want to use an active filter circuit (band-selective amplifier) to amplify &amp; band-pass filter your received signal, while blocking out extraneous noises.

After the amplify/filter stage, all that's left is to de-modulate your signal (using an envelope power measuring ADC for AM, OOK or PWM; or appropriate FM demodulation) and feed it into the receiving MCU.