For anyone else that stumbles here, it might be useful to have a working version of both of these.
If you want to READ (aka RECEIVE) IR codes, check out something like the “VMA317” module (https://www.vellemanstore.com/en/velleman-vma317-arduino-compatible-ir-infrared-37-9-khz-receiver-2-pieces) – they are ~$2-3/each. The benefit is a nice clean 3 wire (Vcc, GND, and “DATA”) interface.
The code is:
// This #include statement was automatically added by the Particle IDE.
#include <IRremote.h>
// NOTE: Need 5V for VIN
int RECV_PIN = D0;
IRrecv irrecv(RECV_PIN);
decode_results results;
void setup() {
Serial.begin(9600);
irrecv.enableIRIn(); // Start the receiver
}
void loop() {
if (irrecv.decode(&results)) {
Serial.println(results.value, HEX);
//Serial.println(results.value);
//Serial.println(results.value, BIN);
irrecv.resume(); // Receive the next value
}
}
If you want to SEND (aka TRANSMIT) IR codes, check out something like the “VMA316” module (https://www.vellemanstore.com/en/velleman-vma316-arduino-compatible-infrared-transmitter-module-2-pieces) – they are ~$2-3/each. The benefit again is a nice clean 3 wire (Vcc, GND, and “DATA”) interface.
The code is:
// This #include statement was automatically added by the Particle IDE.
#include <IRremote.h>
// Send Pin is A5 (https://www.hackster.io/gusgonnet/infrared-replicator-3c52d9)
// NOTE: Must send each command at least TWICE for most devices to receive it. Wait between sends!
IRsend irsend;
void setup() {
}
void loop() {
// Must send twice for it to work!
// NEC is 32 bits, and the HEX (0xSOMETHING) is straight from your receiver above.
irsend.sendNEC(0x12345678, 32);
irsend.sendNEC(0x12345678, 32);
delay(5000); //5 second delay between each signal burst
}