Having a range of values representing high and low

Hi everyone,

I’m quite new to arduino and have basic knowledge of C++ programming.

I have a project on the go at the moment at university where we are making a MIDI device from the arduino. My idea was to have a laser pointing at a light dependent resistor, and when the light was broken (by a hand), it would turn an infrared sensor to ‘high’, which would be located just under the laser.

Would it be a case of saying…

if (LDR < threshold){
digitalWrite(LDR, HIGH);
}

I have tried this before but unsuccessfully!

Just wondering if anyone would have any suggestions for code in this scenario.

Thanks so much.

if (LDR < threshold){
     digitalWrite(LDR, HIGH);
}

Well you wouldn’t want to write the pin HIGH if that’s where you are getting your reading from. You could use the if statement you have there and put code inside to do whatever you want to do if the reading from the LDR is below the threshold. If it is an analog device, like an LDR, then you won’t be using HIGH and LOW to make decisions.