I believe at the point in the code:
irsend.mark(0);
turns on the IR emitter but I can't find what value turns it off.
#include <IRremote.h>
// Simple Infrared Light Output
// IR LED Transmitter/Signal Sender
#define PIN_IR 3
// IR Detector
#define PIN_DETECT 11
// LED For Success Indication
#define PIN_STATUS 12
// Set up sending functionality from library
IRsend irsend;
void setup()
{
Serial.begin(9600);
pinMode(PIN_DETECT, INPUT);
pinMode(PIN_STATUS, OUTPUT);
// Infrared Output Command
irsend.enableIROut(38);
// Output Infrared Light
irsend.mark(0);
}
void loop() {
// If there is light detected, light up led and send a message
// to the serial monitor window
if (!digitalRead(PIN_DETECT)) {
// Tells LED to light up as long as infrared detector
// sees an IR signal being sent
digitalWrite(PIN_STATUS, !digitalRead(PIN_DETECT));
Serial.println("IR Light Detected!");
digitalWrite(PIN_STATUS, LOW); // sets the LED off
}
}
irsend.mark() Sends IR signal for given time ( microseconds ) . I presume value 0 turns output ON permanently. Try to change it to irsend.mark(10000) and se what happens .
Doesn't seem to allow the IR LED to shut off no matter how small a value I put in there besides zero. I am prolly goofing it up. Thank you, though.
digitalWrite(PIN_IR, LOW);
Does have the desired effect. Thanks for that. Very nice way of generically just getting it lit up and off like a regular LED.
I do not understand how the if statement at the line:
if (!digitalRead(PIN_DETECT)) {
is working.
To me it seems to be saying, "if there is no input detected".
What does that line really mean? EDIT:
According to definition:
LOW
The meaning of LOW also has a different meaning depending on whether a pin is set to INPUT or OUTPUT. When a pin is configured as an INPUT with pinMode, and read with digitalRead, the microcontroller will report LOW if a voltage of 2 volts or less is present at the pin.
It seems possible that it is saying, "If not LOW" which is zero or close to zero volts. ??
Turn on the regular LED light if nothing detected? EDIT: I think I at least see this line is saying, "Change the pin status to match the true or false statement." So if theres an on or off, match it.