# Project to distance measure with LDR and LED

need to build circuit with Ldr , led and arduino
how i do it?
my teacher said that we need to calibrate it first. we cant use in delay only in interrupts
we need to convert the light to some value of distance (create some function)
the max-min value between (0-60mm), please help me what i need to do , maybe some basic pattern for it?
this is what my teacher said with no other examples or even block diagram:

First Sketch designed for calibration must
Once per 1 seconds measure “the difference” (as explained in the lecture)
** (timers and interrupts must be used)**
**2. Send “the difference” to serial monitor. **

By using any means and tools (as manual as automatic) , build Graph
** “the difference” [D] versus “distance between LED and the photoresistor as measured by a ruler” [L]**
** This Graph will be used to create “calibration function” L = function(D) **

You need to show us your lecturer notes to be able to answer the rest.

Better still, tell us your teacher’s email.

Do your homework for you: forget it.

just help me how to calibrate, tell me what i need to do

Take a measurement with a known brightness and distance.
Take another measurement with a known brightness and a different distance.
Rinse and repeat

i need to save in the same light ? if i go to other place the measurement will not be correct

It will only work (and even then, not very well) in absolute darkness

On top of ambient light, any change in alignment of the LED vs LDR will also affect your readings (try it out and see for yourself!)

TheMemberFormerlyKnownAsAWOL:
It will only work (and even then, not very well) in absolute darkness

Speculating from context, the point of the exercise is to demonstrate competence in using interrupts on Arduino and how well the distance measurement works in practice is largely irrelevant. Also generating and using the calibration table seems to be a key requirement.

I can't even remember why, but I once tried something like this (over greater distances) and the power LED on the Uno was screwing things up until I taped over it.

I really don’t see how interrupts could be used in this application.

wvmarle:
I really don’t see how interrupts could be used in this application.

end-of-conversion?

wvmarle:
I really don't see how interrupts could be used in this application.

I read the bolded requirements in the original post to say that the LDR state shall be sampled once per second on a timer driven interrupt.

Just re-read the OP. Indeed, it seems they're looking for a timer interrupt.

Typical homework type of assignment.

sorry, my mistake,
I need to do it in the timer interrupt.
I do not expect that you will solve my homework only to give me some ideas/clarifications...

I'd start here: arduino timers and interrupts - Google Search

If you run into specific issues, people here will likely help, but there needs to be some effort on your part.

OP, in fact, the comments here are already pointing you in the right direction... unless you missed the classes and class notes, in which case all the preceding comments will be wasted.

Show us your proposed hardware configuration / wiring and layout.
As you hit specific obstacles, ask here, and we can look at the same environment as you... that will make the conversation much faster.

When you post your code and images, use the forum guides to do it properly, or that will slow things down even further.

wvmarle:
Just re-read the OP. Indeed, it seems they're looking for a timer interrupt.

Typical homework type of assignment.

I really do worry when a teacher sets an assignment which specifies that interrupt must be use to perform a task that clearly should not be performed using interrupts.

Paul__B:
I really do worry when a teacher sets an assignment which specifies that interrupt must be use to perform a task that clearly should not be performed using interrupts.

Homework problems are commonly contrived to align with the course subject material, but I'm not seeing where having a periodic task initiated from a hardware timer interrupt is a bad approach. It isn't strictly necessary in this case because the processor isn't doing anything else, but it is a common approach to multitasking and/or optimizing power consumption.