Pages: [1]   Go Down
Author Topic: Reading IR sensor, returns inconsistent readings  (Read 864 times)
0 Members and 1 Guest are viewing this topic.
Offline Offline
Newbie
*
Karma: 0
Posts: 2
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Hi I recently got my arduino.
So now Im trying to read on IR sensor that I salvaged.
I made a circuit and tested the circuit with my voltmeter, it behaves as I would expect, without shining the IR led on the sensor my voltmeter reads about 0.25v then when I shine the IR led on it, it shoots upto 5V.

So now im trying to read the sensor from my arduino, but as soon as I connect the IR sensor to Analog0 the reading on the analog pin goes up to 900+ sometimes even 1024.
Im not sure what Im doing wrong, I would expect the reading to be something like 51. (5/0.25 = 20, 1024/20=51)
Also my IR sensor is in an plastic enclosure to reduce stray IR light interference.

This is the sketch im using, not much to it.
Code:
int analogPin = 0;
int val = 0;

void setup()
{
  Serial.begin(9600);          //  setup serial
}

void loop()
{
  val = analogRead(analogPin);    // read the input pin
  Serial.println(val);             // debug value
  delay(1000);
}

And this is my schematic


And this is a sample of some of the serial output, (not shining the IR led at the sensor)
Code:
995
1021
1019
1015
1014
1010
1000
983
972
940
940
941
944
945
951
950
953
965
971
985
998
1012
1011
1023
1023
1023
1023
1023
1023
1023
1023
1023
1023
1023
1023
1023
1023
1023
981
982
994
862
1023
1023

I appreciate any help, Thanks.
« Last Edit: January 17, 2013, 12:51:40 am by ObedientSheeple » Logged

Offline Offline
Faraday Member
**
Karma: 80
Posts: 3790
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Maybe it needs to be collected as divider.... Something like the pic attached, which I know isn't exactly what you have.


* Capture.JPG (23.95 KB, 416x287 - viewed 33 times.)
Logged

Although I answer in good faith, remember always: Your Mileage May Vary.
Get me on LinkedIn: za.linkedin.com/in/jimbrownza/

Offline Offline
Newbie
*
Karma: 0
Posts: 2
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Thanks that works.
I now get high values when neutral, and it goes lower whenever I shine the led.
Logged

Offline Offline
Newbie
*
Karma: 0
Posts: 34
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

ham... but i didn't got i read this post afterwards and posted my same question in another post. I want to use IR Led (White is emmiter i think and black is collecter) and i want to use it for pulse detection or say on-off switch can it be used for distance measure too ? I know Ultrasonic sensor is for that...


* 060213-2139.jpg (8.22 KB, 320x240 - viewed 8 times.)
Logged

Pages: [1]   Go Up
Jump to: