106
Wirelings / Re: Using Wireling IR-Emitter and Receiver to detect beam breaks?
« on: May 10, 2022, 06:14:44 PM »
Hiya,
I think I got the example working. It looks like the library changed the way it initiates the IRsend object since that blog was posted, so you would want to use:
Here's the full modified example I got working with some comments. I uploaded this on a WirelingZero with ports 1 and 2. The status LED flashes when I move the Emitter away, so I believe it is working as expected, but I'm not exactly an expert on beam breaking, so let me know how it works for you!
I think this example could be improved with some output in the Serial Monitor so we know exactly what's happening since the status LED doesn't give me 100% confidence that I understand what signal's being picked up.
I hope that helps.
Cheers,
Réna
I think I got the example working. It looks like the library changed the way it initiates the IRsend object since that blog was posted, so you would want to use:
Code: [Select]
IRsend irsend(PIN_IR);
rather than: Code: [Select]
IRsend irsend;
Here's the full modified example I got working with some comments. I uploaded this on a WirelingZero with ports 1 and 2. The status LED flashes when I move the Emitter away, so I believe it is working as expected, but I'm not exactly an expert on beam breaking, so let me know how it works for you!
Code: [Select]
#include <IRremote.h>
#define PIN_IR A1 // This is the IR Emitter on port 1 of the Wireling adapter
#define PIN_DETECT A2 // This is the IR Receiver on port 2 of the Wireling adapter
#define PIN_STATUS 13 // The status LED - normally pin 13 for the majority of Arduino boards
IRsend irsend(PIN_IR);
IRrecv irrecv(PIN_DETECT);
void setup()
{
pinMode(PIN_DETECT, INPUT);
pinMode(PIN_STATUS, OUTPUT);
irsend.enableIROut(38);
irsend.mark(0);
}
void loop() {
digitalWrite(PIN_STATUS, !digitalRead(PIN_DETECT));
}
I think this example could be improved with some output in the Serial Monitor so we know exactly what's happening since the status LED doesn't give me 100% confidence that I understand what signal's being picked up.
I hope that helps.
Cheers,
Réna