Using the VCNL4040 for distance And light sensor simultaneously isn't working

Hi,

I’m using Arduino to control an interactive circuit where an Arduino Nano controls a WavTrigger sound board to play certain sounds in daylight and different ones in darkness, and depending on how close the user is to the circuit. I was using a temt light sensor to sense light conditions and a VCN4040 sensor for proximity sensing, but a friend of mine told me the VCNL4040 should be able to do both jobs at once, controlled by the Arduino code. However, I am finding that this is not working. Sometimes it works perfectly, at other times the Nano board ignores the light sensor input from the VCNL4040 sensor, in light or darkness. I’ve tried multiple VCNL4040 sensors and multiple Nano boards, and I get the same results. My friend assures me it’s not the Arduino code that is to blame.

Can the VCNL4040 multitask in handling light level sending and proximity sensing at the same time, or do I need to return to two different sensors when controlling this circuit through the Nano board? Is this a component issue or a coding issue?

Any input on the VCNL4040 sensor or Arduino code is welcome. Thanks.

https://github.com/sparkfun/SparkFun_VC … adings.ino