Detect rem phases

I will use ir led emitter/receiver for detecting rem phases, the ir led shines on eyelid and the phototransistor will detect if the eye is moving like we are in rem ... 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.

Best bet is to start by just dumping the data to the serial port.

You can then look at it properly. The aim is to identify some characteristics that are unique to each phase. This should be as simple as possible. Average and rate of change are likely good indicators, but you will need some solid data to work with.

Can you read the sensor from code?

Yes, sure, i read the sensor via the analog input. :smiley: