I have a Nano, CHQ1838 IR sensor & IR LED (unknown p/n / specs). I'm trying to use it as a light curtain.
IR Detected - Pin 13 high (On board LED)
beam broken by object, Pin 7 High, Pin 13 Low
I'm using the Arduino-IRremote library & started with the example given in the library authors blog
I've also added the resistors/capacitor indicated in the IR sensor data sheet circuit, with no difference in operation.
On power up, the sensor detect IR for ~1s (no scope to view, but it is about 1s). After that, it stops detecting IR, until you cover the sensor or unplug the LED, then it will detect for 1s. If I plug/unplug the LED as fast as I can, it responds instantly as far as I can tell.
Is the receiver sensing 'noise' since the LED is on all the time? I've tried various ideas to turn the LED off for 600us, but haven't found anything that works (irsend.mark(600), irsend.space(600), delay(1), etc). Either I get no effect, or I get NO detected IR.
Any suggestions, I have a feeling the answer is simple, but I'm not seeing it.
//Arduino Nano v3.0
//CHQ1338 IR Receiver - IR Receive = LOW
#include <IRremote.h>
#define PIN_IR 3 //LED + 470ohm
#define PIN_DETECT 2 //CHQ1838, Pin 3
#define PIN_STATUS 13 //On Board LED
#define PIN_VALVE 7 //Pnuematic Valve (LED Simulating)
IRsend irsend;
void setup()
{
pinMode(PIN_DETECT, INPUT);
pinMode(PIN_STATUS, OUTPUT);
irsend.enableIROut(38); //PWM IR LED @38khz
irsend.mark(0);
}
void loop() {
digitalWrite(PIN_STATUS, !digitalRead(PIN_DETECT)); //IR Detected = LED ON
digitalWrite(PIN_VALVE, digitalRead(PIN_DETECT)); //IR NOT Detected = Valve cycle
delay(20); //Cyl extend
digitalWrite(PIN_VALVE, 0);//Turn valve off
delay(20);//Cyl retract
}