IR switch

Hello, I have an IR LED and VS1838b IR Receiver. I want to make this:

I want when the connection between the IR transmitter and IR receiver is disconnected (for example by putting my hand between) to get a signal on serial. I will use Arduino MEGA.

How do I do this? Should I continuously send a pulse train, or just continuous light from IR transmitter?

Thank you

The good part of programming is you can try to see if things work. :wink:

The VS1838B is designed to detect a train of 38kHz pulses.

It won't detect a continuous IR light source.

See the [datasheet](http://"http://"http://www.elecrow.com/download/Infrared receiver vs1838b.pdf"") for more information - sorry, but it is in Chinese.

JohnLincoln:
The VS1838B is designed to detect a train of 38kHz pulses.

It won't detect a continuous IR light source.

See the [datasheet](http://"http://"http://www.elecrow.com/download/Infrared receiver vs1838b.pdf"") for more information - sorry, but it is in Chinese.

So I can't make it work like IR switch?

Generating 38kHz, and driving an IR LED with that is easy.

const byte IR_LED = 11; // IR transmitter LED with 100ohm CL resistor

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

void loop() {
}

Next problem is the receiver.
It's likely designed for intermittend 38kHz bursts, like from a remote.
Only certain receivers, like the TSSP4038 (not TSOP), are made for continuous IR.
Leo..

Thank you! If I use the classic (black painted) IR receiver is more simple to make the IR switch?

I don't want to guess.
There are many different black IR receivers.
And I don't know what exactly you're trying to do (distance etc.).
Maybe you just need a reflection/distance sensor.
Be specific with your requirements.
Post a diagram, links to datasheets, code, etc.
Leo..

alex5678:
Thank you! If I use the classic (black painted) IR receiver is more simple to make the IR switch?

I think that you will find that the device is encapsulated in an IR transmissive polymer, rather than just being painted black!

The sketch using one may be a lot simpler, however I think it is worth persevering with the VS1838B if you already have one. It should be more insensitive to ambient light conditions, and interference from fluorescent lighting etc. and give you a better range.

Experiment with what you've got.

@JohnLincoln: I was only describing the LED to be more accurate!

@Wawa: I just want everytime I pass my hand through the Infrared connection (between Transmitter, Receiver) to get a signal on the output...