LDR with Timer and Stopwatch

Dear engineers and developers,

Let me first introduce my self, I am a medical engineer student 20 years of age.

A few week ago at mt internship I got a project to make a device who can measure how long an other device has been on.

the Idea is to make a stopwatch/timer with a LDR. An electronic device has always a light indicator that is on while the device is on. So when the device shuts down the light indicator goes off, the LDR will measure a value of less than 300 and will stop the timer/stopwatch.

I kinda modified a code from someone else for the stopwatch.

But now there must be a timer included. but that got a little to difficult, because I never programed of worded with the arduino before. The great thing about open source is there is always some part of your program made by others.
I found this;

I do not understand it because there is to less commentary, I basically asking you guys to help me modify it that the timer and stop watch stops when the value of the LDR is <300 and to let it count till 24 hours.

ps. english is not my native language .


It is much easier for us if you post the code (within code tags) directly in your post.

Also, life is too short to wade through programs full of LCD stuff that has nothing to do with the question.

I think what you are trying to do should be very simple.

When the light goes on record the value of millis() as in startMillis = millis()

When the light goes off record the new value as in endMillis = millis()

And you get the duration by subtracting one from the other.