So I apologize that I'm new to the Arduino. I am working on a geocaching idea and I want my code triggered via IR. I picked up from Radioshack a 276-0142 IR emitter and detector set.
My idea is to have the IR detector trigger my Morse code sketch once the IR is detected (provided by a remote control the user will have). The Morse code sketch works great but I haven't used inputs before.
Well it looks like you take the emitter and treat it as a standard 1.3v forward drop LED. 5v supply and a resistor. You calculate the resistor. You can use on online calculator. The comments on the Radio Shack site imply shoddy quality and the need to pay attention to the polarity of the emitter which may not be immediately obvious (different length anodes, etc) . Read them and look at yours. I'm sure you can set it up with the BLINK sketch to make it blink. Apparently one can use one's cell phone to verify the blinking.
The detector appears to be a phototransitor. Looks like it will have a higher voltage reading when it sees infrared than when it doesn't. I would hook it up and look at it using analogRead (http://arduino.cc/en/Reference/AnalogRead#.UxzqbPmuRQo ) and the serial window and see what the voltage readings look like as it is exposed to the emitter. That should tell you a lot. Test it with the emitters the users will have.
Once you have a handle of those two pieces figuring out how do something in a sketch after the detector sees a voltage change should be within reach.
AnalysIR:
It really depends on how/where this will be used. This setup will typically get lots of interference from ambient light, particularly sunlight.
Yes, I would expect so also. OP may have to get creative in mounting the detector in a shielded fashion somehow.
AnalysIR:
It really depends on how/where this will be used. This setup will typically get lots of interference from ambient light, particularly sunlight.
Update:
I decided to swap out the Radioshack IR combo pack for the Radioshack 276-640 IR detector.
So here is where my problem lies:
Everywhere I have looked online people are wanting their remotes to do something specific based on the different codes from the different remote buttons. All I want the IR Detector to do is to act as a switch. I don't care what code is obtained through the IRRemote library... If there's a signal, I want it to turn on the LED and run the rest of my code...
The issue I am having is the way that the library is setup the 'results' variable is an object and I cannot use operators like I am used to (i.e. !=, >, NULL, etc. ).
I'm sure there's a way to bypass the library. I'm just too new to know the correct way.
Any help/insight would be greatly appreciated!
Thank you!
#include <IRremote.h>
int RECV_PIN = 2;
IRrecv irrecv(RECV_PIN);
decode_results results;
int LED_Pin = 11;
String message = "Testing 1 2 3"; //Replace the text inside the quotes with your message. Inputs a String
int len = message.length(); // Measures the length of the String message
boolean IR_Input = false;
void setup()
{
irrecv.enableIRIn(); // Start the receiver
pinMode(LED_Pin, OUTPUT); // initialize the digital pin as an output.
Serial.begin(9600); // initialize the serial output at 9600 baud.
}
void loop()
{
if (results != NULL)
If all you want to do is detect IR, not decipher some level of pulses and convey info, why are you even using an IR library?
I don't know about the new sensor, but for the first one, if the sensor sees IR the signal voltage increases. There is your trigger, no library required.
If you are in a cave with no obstructions, I would still go with the library for the IR sender as it gives you a modulated signal. (= more immune to interference). You will only have to deal with a digital signal (vs analogue using your original sensor)
Alternativeley, you could use most common remotes to act as the trigger.
On the receiver end you could just attach the IR receiver output to one of the interrupt pins (INT) and use attachinterrupt to detect the signal.