I was thinking of using a PWM signal for the LED. 12F683 could be handy here.

Start the HPWM of x KHz, and use the internal timer to count in background. With a decent prescaler, it should reject most part of the ambient light.

Just an idea... in theory it works.