Making sensors not to sense under particular condition

Hi

Is there any code or function which stops sensing ability of sensors. I want to make my sensor not to sense under particular condition.

If the condition is true then don't read the sensor

if (condition == false)
{
  //read the sensor here
}

You can't stop the sensor from sensing, unless you can power it off. You can care, or not, what the sensor senses.

Why do you think you need to stop the sensor from sensing? What sensor?

I am using LDR sensor and it is continuously sensing which requires power. I want LDR to go in idle state if threshold is in particular range so that power drainage should be less.

Supreet:
I am using LDR sensor and it is continuously sensing which requires power. I want LDR to go in idle state if threshold is in particular range so that power drainage should be less.

How is the threshold set ?

I want LDR to go in idle state

What the heck does this mean? Does your LDR really have an idle state? I've never seen one that did.

You COULD power the LDR from a digital pin, and turn it on or off as necessary.

Supreet:
I want LDR to go in idle state if threshold is in particular range so that power drainage should be less.

What threshold?

An ldr is a resistor. You have voltage across it. There will be current. I can't recall the resistance off hand, and it's usually in series with another resistor as a divider, so the current is surely tiny?

The only way to prevent it drawing power is to disconnect it.

And assuming you could stop it reading when under a certain threshold, how would it know to turn back on above the threshold since it's no longer reading?

dougp:
What threshold?

I have a sense of impending doom that it is going to involve the light level...

UKHeliBob:
I have a sense of impending doom that it is going to involve the light level...

That would be amazing.

To the OP- you could always use a MOSFET or relay to disconnect the LDR from the circuit.

neiklot:
how would it know to turn back on above the threshold since it's no longer reading?

Wait, I know how: have another one monitoring the level to tell the first one to come back on?