sorry but i will use ir led for more precision of detecting Rem phases, but i don't know how to write the code to make me sure that my device has detected rem phase.

So we need to:
1.) read from the sensor with eye opened and hold viewing the sensor
2.) read from the sensor with eye opened and moving it
3.) read from the sensor with eyelid closed

all of these values will be stored in variables.

but when i wiil check if we are in rem phase i don't know how to proceed...with a simple if it doesn't work...too much false positive.

Any suggestions?
THX.