Ir detection circuit help

I update the circuit and code. I also deleted the image of the circuit so as not to mislead others.
Please see my updated circuit and code.
Thanks to:

Old post:
I am creating an Arudino UNO IR detector project that will serve as a motion detector.
I've attached an image.

I have three questions.
-? RESISTOR - What is the function of the resistor with respect to the IR LED and IR DETECTOR ?
(I've always attached a resistor to and LED to protect the LED.)
-? Should I use something more than a 220 ohm?
-? A0 Input. I am using A0 for detection and I've seen some circuits that use something like pin 2. What is the fastest way to get IR detection.

  • The IR LED (and all LEDs) operate by a current passng through them, the series resistor limits the current. Applying a voltage across the LED will allow an uncontrolled current through it.

  • An IR LED has a typical volt drop of ~1.7 V. With an Arduino power supply of 5V and assuming the output voltage is also 5V, the current through the 220R is (5-1.7)/220 = 15mA nominally. I would expect this to be fine for your unspecified LED. 10mA to 20mA is fine for most LEDs.

  • How fast do you want the IR detecting to occur?

  • For an example of IR detecting see this: How to Build an Infrared Detector Circuit

Let us know how you get on :slight_smile:

Thank you for the post. I need the detection to be immediate.

My code is not working well:


const int analogInPin = A0;  // Analog input pin that the receiver is attached to

int sensorValue = 0;        // value read from the receiver

void setup() {
  // initialize serial communications at 9600 bps:
  Serial.begin(9600);
  //initialize the indicator LED:
  pinMode(13, OUTPUT);
}

void loop() {
  // read the analog in value:
  sensorValue = analogRead(analogInPin);

  // print the results to the serial monitor:
  Serial.print("\nsensor = ");
  Serial.print(sensorValue);
  //the threshold found fron analog In Out program was when object is detected, the sensor value is below 100
  //set the threshold whihc you get
  //the threshold varies for different sets of emitter-receiver pairs
  if(sensorValue < 100){ //checks if object is there or not
    digitalWrite(13, HIGH);
    Serial.print("\nObject Detected");
    }
  else{
    digitalWrite(13, LOW);
    Serial.print("\nNo object in Front");
    }
 // delay(500);
}

... in what way, exactly?

So, 0.0001 femtoseconds? 1.0 nanosecond? 1.0 microsecond? 1/10 second? etc.
Please be specific.

Also tell us your actual resistor values.

Have you considered donating your breadboard to a charitable organization? You don't seem to be using it.

thanks for the reply.
1 micro second should work.
Both resistors are 220 ohm.

I am not getting any value other than 0 for : sensorValue

It's been a few years since i have done this so I'm not sure on my circuit.

LOL. I am using the breadboard.

I got the circuit to work. I will update the arduino circuit and code once it is cleaned up. There was a lot of misleading code in www land.

I cannot advise on the code - not my area of expertise.
Hmm, immediate. What less than a nanosecond or a picosecond? I guess you mean 'immediate' in human determination terms; so tens or hundreds of microsconds.
I have just had a quick look at your circuit:

  • The IR LED is conencted across +5V and GND, so will be emit when the power is applied. There is no timing associated with its operation.
  • I am suspicious that the amount of voltage generated by the IR detector will not be enough to be detected.
    Can you measure the voltage across the detector with a voltmeter; both with it illuminated and not (could use finger,say, to cover it rather than power the transmitter on/off).
    As a test point the LED directly at the detector with close to zero gap. You will not get better coupling than this.
    The IR detector is a current source (assuming that it is a photodiode) and will generate current, not voltage.
    The usual method of detecting current is with a transconductance amplifier (Transimpedance amplifier - Wikipedia)
    image

More complication for you I'm afraid :wink:

Thank you for the post! I got the circuit to work and I really like circuit . My son is an EE he will be able to help with it. I originally did not follow a good design I found on the internet.
Makersportal.com was very helpful.
Infrared Obstacle Detector for Less Than $1 — Maker Portal
I will re-post my solution after I do some more testing.
I was not powering the IR detector,
Now the question is to use pin 2 to supply voltage or 5v/3.3v to the IR detector.

Here is a circuit that works for me. I do use a breadboard.
I modified the makersportal.com circuit.

code:

//https://makersportal.com/blog/2018/1/17/infrared-obstacle-detector-for-less-than-1
//https://makersportal.com/shop
//Photodiode to digital pin 2 optional
int led=13;                   //LED to digital pin 7  
int senRead=0;                 //Readings from sensor to analog pin 0  
int limit = 1000;            // play with system to find this limit (10K ohm resistor used)
void setup()    
 {  
  pinMode(led,OUTPUT);  
  digitalWrite(led,LOW);      // LED initially off  
  Serial.begin(9600);         
 }  

int val = 0;
void loop()  
 {  
  val=analogRead(senRead);  //photodiode reading
  Serial.println(val);      
  if(val <= limit)             // NO OBSTICLE 
  {  
   digitalWrite(led,LOW);     // LED OFF
   delay(20);  
  }  
  else if(val > limit)        // OBSTICLE DETECTED  
  {  
   digitalWrite(led,HIGH);      //LED ON
   delay(20);  
  }  
 }  

Good that you got the circuit to work :slight_smile :slight_smile:
Wht did you change?
I saw that in the maker Portal schematic that the IR detector was biased through 1Meg resistor.
The maker circuit does show the IR LED continuosly powered i.e. from the 5V supply via 47R resistor = lots of current, 70mA nom. The change being the reflecting from the detected object - I was unaware of this previously.

I added a 220 ohm to the IR LED and a 10K Ohm to the IR PHOTODIODE.
I also provide 5VDC from the Arduino 5V.
I will put 3 IR LED/ PHOTODIODE at 0cm 100cm and 110cm along a PVC pipe and drop a ball to simulate Galileo's discovery the the FINAL VELOCITY of a falling object is double its MEAN.

I'm a teacher / developer.
The project has a lot of industry applications as well.

1 Like

Best of luck :slight_smile:
This typre of sensor may make your mechanics easier:
image

Yes, several decades of such applications from which you could learn.

1 Like

This topic was automatically closed 180 days after the last reply. New replies are no longer allowed.