I'm pretty new to Arduino, so please forgive my ignorance...
I'm trying to build out a remote control receiver via Arduino. I bought an emitter/detector pair from Radio Shack (276-142). I have the detector wired up to pin 2 as shown in the "Arduino-Based Optical Tachometer" Instructable (pin 2 -> 10K resistor -> IR -> ground). I'm using very simple code just to see if I can register anything.
Unfortunately, running this code results in no interrupts and I'm a bit confused about what might be going on. I'm using a standard universal remote control.
Doh... I was trying to clean up my post and deleted too much. This is my full code (including all of the comments I was trying to clean up). This is the code that is running and has the attach interrupt.
int loopCount = 0;
volatile int interruptCount = 0;
void interrupt_func()
{
interruptCount++;
}
void setup()
{
Serial.begin(9600);
Serial.println("Starting...");
//Interrupt 0 is digital pin 2, so that is where
//the IR detector is connected
//Triggers on FALLING (change from HIGH to LOW)
attachInterrupt(0, interrupt_func, FALLING);
// Use statusPin to flash along with interrupts
// pinMode(statusPin, OUTPUT);
}
void loop()
{
//Update RPM every second
delay(5000);
Serial.print("loop ");
Serial.print(loopCount++);
Serial.print(" interrupts ");
Serial.println(interruptCount);
//Don't process interrupts during calculations
// detachInterrupt(0);
// rpmcount = 0;
// Write it out to serial port
// Serial.println("Loop");
//Restart the interrupt processing
// attachInterrupt(0, rpm_fun, FALLING);
}
Can anyone explain the difference between IR detectors that have three connections versus the IR receiver I have with 2 connections? Is this why I'm having trouble?
The part you have (276-142) is a phototransistor.
The 3-lead (276-640) part is a specialized module for 38kHz IR, which is a common frequency used for (TV) remote controls.
You may be able to get the part you already have working for remote receiving (radioshack spec.s don't say anything about response time), but it would probably take quite a bit more circuitry/testing to get it there.
I notice that there is no digitalWrite(pin2, high);
This will enable the pull up resistor on pin 2 which will allow current to flow in the photo transistor. Without it, or a pull up resistor I can't see it working.
EDIT. Just looked at the comments on that schematic page and agree that the hand drawn picture of the photo transistor will work a lot better and won't need the internal pull ups enabling.
Thanks for the responses. I just picked up the 3-wire 38Khz IR receiver and it seems to be working. Now it is a matter of software... Which I'm much better with.