Go Down

Topic: unable to read ir sensor value (Read 1 time) previous topic - next topic


Nov 25, 2009, 01:46 am Last Edit: Nov 25, 2009, 01:47 am by eranglr Reason: 1
Ok, now I get a difference of 400 to about 650!
(changed the led positions and resistors)


Nov 25, 2009, 01:54 am Last Edit: Nov 25, 2009, 01:59 am by Aniss Reason: 1
Still rather little...I'm getting something like ~7 vs. ~900 (depending on light conditions).

Keep tweaking ... like I said you're almost there ;)

PS: Are you sure you set the scope to the right COM port when you tried it? I really can't figure out why it wouldn't work?! Also the Arduino serial monitor cannot be open at the same time by the way...


The question is how to get those values that you'r getting?
Do you have any idea about the specific resistors? what are the rules to the sensitivity of the phototransistor? can't I accidently destroy it using wrong resistor?


can't I accidently destroy it using wrong resistor?

You can destroy the LED if the value is too low. But according to the diagram you had 150R which is about the right value. But you got more light when you changed it to 1K so that suggests you didn't have 150R in the first place.

what are the rules to the sensitivity of the phototransistor

Not sure what you mean here. The photo transistor will cause a current to flow from collector to emitter depending on the amount of light. That current affects the voltage on the output as the current flows through the resistor. So the higher the resistor the more change in voltage you will see for the same change in light levels.


Jun 19, 2010, 01:25 am Last Edit: Jun 19, 2010, 01:56 am by yeahsure Reason: 1
Hi, first post here!

Newbie to electronics and the Arduino.

I have a Duemilanove and I'm trying to build this very same circuit for obstacle avoidance, but I can't get it to work. I've spent the whole day trying to figure out what may be the problem, but so far no luck.

I've changed the 150 resistor in the first post to a 330 and 1k. The 47k has been replaced with a 10k resistor. I'm using a generic IR Led and Phototransistor - the electronics shop where I bought them didn't told me if they had a specific name or model, just that they were generic.

The code I'm using is this:

Code: [Select]

void setup() {
pinMode(1, INPUT);
void loop() {
   int val = analogRead(1); // read sensor input from analog input 1
   Serial.print(val); // send the value to scope
   Serial.print(" ");
   delay(500); // wait 1 millisec

So far when I turn off the light near my desk, I always get a reading of 1023 using the Serial Monitor. If I turn the light on, it goes down to 1017, so I know *something* is happening.

I've already verified that everything is correctly connected, on the right pins, right polarity, etc.

Could you please, please help me!? I'm about to loose my mind!  :'(

Go Up