A bit of quick Arduino help requested - IR BreakBeam sensor


 

Andy Snider

TVWBB Fan
Hopefully someone can help quick - I bet it's a simple thing I'm overlooking.

I have an IR sensor (like a remote sensor) & an IR LED (circuit works with a visible LED & I can see IR on via phone camera).
Amazon link:
http://www.amazon.com/exec/obidos/ASIN/B00EFOQEUM/tvwb-20

running the LED at 38khz, as per example:
http://www.righto.com/2010/03/detecting-ir-beam-break-with-arduino-ir.html

I'm getting ~1s of detection when I power up & <1s when I break the beam & it resets. Other than that, it's not detecting the IR LED.
Is it rejecting 'noise' since the IR is on all the time? How do I pulse the already PWM'd signal?
I've tried a bunch of stuff, nothing affects it, other than making it not detect at all...
my circuit looks like the above example, very simple 1 LED, 1 Resistor & the IR receiver. I don't have a scope, but my multimeter reacts when I get the sensor to trip. I'm just not sure why it stops seeing the beam.

Code:
//Arduino Nano v3.0
//CHQ1338 IR Receiver - IR Receive = LOW
#include <IRremote.h>

#define PIN_IR 3 //LED + 470ohm resistor ~10mA
#define PIN_DETECT 2 //39kohm to 5v
#define PIN_STATUS 13 //internal LED
#define PIN_VALVE 7 //Pnuematic Valve

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
}
 

 

Back
Top