11,397

32

12

this instrument can detect precisely any object from a distance of 40 cm to 0.5 cm.
and this can actually calculate the distance of the object .
Here i will use this feature to analogWrite the LED.  which will incerease its brightness as the distance gets lesser ...

### Teacher Notes

Teachers! Did you use this instructable in your classroom?
Add a Teacher Note to share how you incorporated it into your lesson.

## Step 1: The Circuit

You Can Build this with these Materials :-

-Arduino (Uno)
-Jumper Wires
-Resistors(10K,330OHMS)
-LED(Indicator ,any colour)
-IR LED Pair

## Step 2: Coding and Caliberating the Sensor

the code is as follows :-

when there is no object is in front of it then my serial monitor reads 168..

so only if the value is above 170 then the sensor will read the value hence the bolded number is a bit more than your normal sensor value .......

The minvalue is the variable used for that purpose ...!

[CODE/]

int led = 9 ;

int minValue = 170;

void setup() {
Serial.begin(9600);
pinMode(led,OUTPUT);
}

void loop() {
if (sensorValue > minValue){

int val = map(sensorValue, minValue, 980 , 0, 255);

analogWrite(led,val);
Serial.println(sensorValue);
}

else {
digitalWrite(led,LOW);
}
}

[/CODE]

Participated in the
Sensors Contest

Participated in the

161 8.0K
24 1.5K
61 3.7K

## 12 Discussions

hello, I would like to make water level IR sensor. I think about use tube, where at top I add IR receiver and trasmitter. And bottom of tube, I use some plastic thing to reflect ir wawes. My question is, how accurate is IR? I know it depend on ambient light, so I would like to use total dark (I make plastic roofs on top tube, max. from bottom some light, ).

So, the sensor output value is a voltage in the range of 170 to 980, correct? is that millivolts? microamps?

The sensor output range will depend on your power supply, right?

i'm thinking you could take the Arduino out of the circuit, and drive the LED directly from the sensor, no? Maybe with a boost transistor.

thx

2 replies

It's the Arduino's ADC value, each unit is equivalent to roughly 4.8 millivolts. The scale is 0v-5v.

could i get rid of the arduino and just mesure the voltage output of the ir led?, will it be proportional to the distance?