IR sensor pulsing

Hi guys,

Having a little trouble with an infrared receiver.

For some reason, when I hook this up to my arduino uno, it sends a pulsed signal constantly, can anyone tell me how to stop this, as I only want it to read high when an infrared light is detected.

The IRsensor that I am using is a Sharp IS471F

An infrared led is used as the signal source attached to a push button, power for the sensor and the led both come from the 5V pin and ground back to the arduino.

The system works, in that when the button is pushed, the readout on the monitor goes HIGH (about 80) and stays there while the button is pushed, but when not pushed, the readout goes back down to 0 and then pulses a high signal anywhere from 67 to sometimes 81.

Here is my code, this is set up so that when an infrared light is detected, then the signal from the IRsensor on Pin A0 lights the red led attached to Pin 13. The if statement for the analogRead was my attempt to compensate for the pulsing, but getting rid of the pulse so that it just reads zero until it gets the signal would be preferable.

//Reads the State of a Pot and displays on screen

int IRPin = 0;
int led = 13;

void setup()
{
  //sets the button pin as an input
  pinMode(IRPin, INPUT);
  pinMode(led, OUTPUT);
  
  //Allows us to listen to serial communications from the arduino
  Serial.begin(9600);
}

void loop()
{
  //Print the button state to a serial terminal
  Serial.println(analogRead(IRPin));
  delay(100);
  if (analogRead(IRPin) > 78)
  {
    digitalWrite(led, HIGH);
  }
  else
  {
    digitalWrite(led, LOW);
  }
  //Wait one second, then print again.
}

I hope this post is set out right, Kind regards Jonny.

Need a schematic and more information about how you have this wired up. This is not just an IR receiver, it’s a proximity detector. Are you using this chip to modulate your LED? Which output pin are you looking at? GLout is a pulse train that runs at about 8kHz.

Ah, yes sorry, the sensor is a TSOP4038 sorry.

jonny_frond: Ah, yes sorry, the sensor is a TSOP4038 sorry.

:/ The output of that sensor is digital, why are you using analogRead()?

The value you print to the serial port is not the same one you make your decision on, so you might want to declare a variable and do just one analogRead(), though I think you should be using digitalRead().

Usually, the output of an IR sensor goes LOW when it is receiving a carrier signal. Your analogRead() statements should be returning values close to 0 and 1023, I can't see why you would get values near 80. Do you have a pullup resistor on the output pin of the sensor?

Right thank you, this is all very helpful. This is my first foray into Infra red and I assumed that it was analog and behaved like a voltage divider like a pot. I will go over my circuit again and will re write my program and will get back to you either with my solution or more questions I'm afraid.

OK, on further investigation, I am starting to think that i have the wrong IR component. Basically, I am building a following robot and was going to use infrared to track direction and ultrasonics to track distance. The plan was to place an IR led on another robot, and the follower will have a receiver that will be on when it sees the led and off when it doesn't. I assumed this to be quite a simple task, but it seems trying to get an IR receiver that does that is not as easy as I thought.

Any ideas guys?

Use a VS1838 or something similar for your purpose.

Thanks for all your help, here is a final post to tell what I have found as I find so many open ended posts that do not have a solution.

Firstly I was using the wrong component, I was using an infrared receiver for a remote. These are set at 38kHz so it was amazing that I got something out of it at all.

Second I had it wired up on the wrong pins, the earth was good, but the signal and power were the wrong way round.

With the Arduino, it seems to send a pulse to empty pins. i.e if you are using a pin for the wrong purpose, then the code you have is activating the pin, but the hardware is not compatible, so a pulse is sent to that pin, whether this is normal or not I would not know, but that was the cause of my pulsing. I think it was because of the pulsing that the system seemed to work, because it was ultimately hitting that frequency at some point.

I now have a paired infrared transmitter and detector and they do what I was after. not yet tested, so I still can't admit to whether analog or digital pin needs using.

Thankyou Mjkzz, I will look into that for other projects in future.

Thanks all who answered.