IR Light Barrier inconsistent signal

I am building an installation where people drop a small round object into a tube, which will trigger a video on a brightsign via GPIO. The ball is detected by a IR barrier, and that is where my problem lies.

I connected the IR Sender to 13 which is on continuously. The IR Receiver is connected to 7, and there are two LEDs for testing, which light up when the IR receiver is receiving signal or not.

My problem: When the IR signal is not interrupted by anything, there does not seem to be a constant signal from the receiver, but a incontinuous blinking. When the signal is interrupted, no problem. Is my wiring wrong? Am I using the hardware wrong?

Hardware:
Arduino Uno
Vishay TSAL6200 IR Emitter
Vishay TSSP58038 IR Receiver

int IRSensor = 7;
int IRSignal = 13;
int sensorValue, pSensorValue;
int objCount = 0;
int ledR = 8;
int ledG = 9;
int timeOut = 5000;
int analogThresh = 500;
int sensorIn;

void setup() {
  Serial.begin(57600);
  pinMode(IRSensor, INPUT);
  pinMode(IRSignal, OUTPUT);
  pinMode(ledR, OUTPUT);
  pinMode(ledG, OUTPUT);
  digitalWrite(IRSignal, HIGH);
}

void loop() {
  sensorValue = digitalRead(IRSensor);
  testSensor();
}

void testSensor() {
  if (sensorValue < 1) {
    digitalWrite(ledG, LOW);
    digitalWrite(ledR, HIGH);
  } else {
    digitalWrite(ledG, HIGH);
    digitalWrite(ledR, LOW);
  }
}

Since your IR receiver is expecting a 38kHz modulated signal, are you modulating the IR LED at 38kHz?

Your drawing shows nothing connected to pin 13 (okay if the drawing is not accurate).
Does the RXIR show "received" when no TXIR is present? (unplug TXIR to test for false RX)
And that 38kHz thing...

Your topic has been moved to a more suitable location on the forum. Installation and Troubleshooting is not for problems with (nor for advice on) your project.

Thanks for providing a schematic and using code tags in your first post; we do not see it often.

Why? The same Arduino can generate that 38KHz with a few lines of code.

const byte IR_LEDpin = 11; // IR transmitter LED with 100ohm (minimum) CL resistor

void setup() {
  pinMode (IR_LEDpin, OUTPUT);
  TCCR2A = _BV (COM2A0) | _BV(WGM21);
  TCCR2B = _BV (CS20);
  OCR2A =  209; // ~209 = ~38kHz | ~219 = ~36kHz
}

Leo..

You can also use the tone() library to generate the 38kHz carrier. The IR sender (LED) needs also a current limiting resistor.
Some of those similar looking receivers, especially those intended for TV remote controls, have built-in interference suppression and don't tolerate extended carrier bursts. The TSSP58038, which is specifically a light barrier sensor, appears not to have such a limitation.

You might need to look at the optics too , IR light might be scattered by the tube Or the object giving false results ?

Some phones can view IR with their camera

The resistor in series with the LED can be a rather high value when LED and sensor are close.
100 ohms, which is in the sketch I posted, could bridge 25m (75ft).
10k could already be ok for a small distance.
Leo..

True. Thank you.

Thank you all for the suggestions! went with the tone library to modulate the signal at 38khz, that worked perfectly for my purpose.

1 Like

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