I am trying to follow this guide: Detecting an IR Beam Break with the Arduino IR Library
The goal is to have one Arduino emit an IR signal, as well as indicate when an IR receiver connected to the same Arduino receives the signal.
I am using the following hardware:
Arduino MKR 1310
1838B infrared receiver
LTE-4206 940nm 60ma IR LED
46 ohm resistor
330 ohm resistor
generic green LED
It is connected as this:
PIN1(output) -> generic green LED -> 330 ohm resistor -> ground
PIN2(input) -> middle leg of 1838B
PIN3(output) -> IR LED -> 46 ohm resistor -> ground
VCC -> right leg of 1838B
Ground -> middle leg of 1838B
The code used is:
#include <IRremote.h>
#define PIN_IR 3
#define PIN_DETECT 2
#define PIN_STATUS 1
IRsend irsend;
void setup()
{
pinMode(PIN_DETECT, INPUT);
pinMode(PIN_STATUS, OUTPUT);
irsend.enableIROut(38);
irsend.mark(0);
Serial.begin(9600);
}
void loop() {
digitalWrite(PIN_STATUS, !digitalRead(PIN_DETECT));
Serial.println(digitalRead(PIN_DETECT));
}
Expectation: When the IR led shines on the IR receiver, the green LED should light up.
But this doesn't happen.
I have troubleshooted and tested the following:
Pointed a TV remote towards the receiver and pushed buttons. The receiver receives the signal and the green LED lights up. This should mean that the issue is either with the IR LED or in the code.
To verify the IR led I loaded the following code instead:
#define PIN_STATUS 3
void setup() {
// put your setup code here, to run once:
pinMode(PIN_STATUS, OUTPUT);
digitalWrite(PIN_STATUS, HIGH);
}
void loop() {
// put your main code here, to run repeatedly:
}
This code makes the IR led shine all the time, and I then pointed a Android tablet agains the LED and I can see it shining. This means the LED is connected properly and working.
I then loaded the first sketch again and looked at the IR LED with the Android tablet but I did not see it shining.
The code from the article has multiple comments about it working for them so I am not sure why the IR doesn't emit any light. Finally I tested with my multimeter and found that there wasn't any current sent out toward the IR LED. Anyone know why?
While which PIN to use for the IR LED is not defined in the code, it seems the IRremote.h assumes it will send it out on PIN 3 which is what I am using.
All the components share the same ground, GND from the Arduino board.
I am using IRremote by shirriff, z3t0 2.8.0