calculation in condition block of if else
Posted: Wed Jan 04, 2012 11:47 am
i m working on an AGV, there r 3 LDR on th front,right and left to sense light. voltage across ldr is read n converted into interger.
front_ldr , right_ldr , left_ldr are values ranging from 0-1023
now the problem is with if-else conditions.
suppose light coming on front and left side is approx. equal so it should turn little left
if(left_ldr-10<front_ldr<left_lrd+10)
then "turn left"
but this left_ldr-10<front_ldr<left_lrd+10 is not working, simulation is showing it is always true whether i change adc input or not.
please help
tell me how to check whether on of the ldr value is nearby(plus minus 10) of another ldr value.
front_ldr , right_ldr , left_ldr are values ranging from 0-1023
now the problem is with if-else conditions.
suppose light coming on front and left side is approx. equal so it should turn little left
if(left_ldr-10<front_ldr<left_lrd+10)
then "turn left"
but this left_ldr-10<front_ldr<left_lrd+10 is not working, simulation is showing it is always true whether i change adc input or not.
please help
tell me how to check whether on of the ldr value is nearby(plus minus 10) of another ldr value.