I am trying to get an IR transmitter and receiver working but I keep running into a brick wall.
I am using a IR LED - TSAL6100 and a receiver TSOP38538. I believe they should be compatible (they operate at 38kHz) and I have kept the wiring as simple as possible to reduce any wiring issues.
The IR LED works fine as long as I define the HIGH and LOW manually but as soon as I try to incorporate the IRremote functions it stops working. I have changed the LED for a standard one and it flickers as expected but when I change it back I get nothing (on my camera which is what I am using to check when it lights) and the receiver just comes back with 0xFFFFFF.
Its my first attempt using IR so I'm very new to it but I can't seem to get past this and I don't know what to try next
#include <IRremote.h>
#define IR_LED_PIN 9 // Pin connected to the IR LED
#define IR_RECEIVER_PIN 3 // Pin connected to the IR receiver
IRsend irSender(IR_LED_PIN);
IRrecv irReceiver(IR_RECEIVER_PIN);
decode_results results;
void setup() {
Serial.begin(9600);
irReceiver.enableIRIn(); // Initialize the IR receiver
pinMode(IR_LED_PIN, OUTPUT); // Configure IR LED pin as output
}
void sendIRSignal(unsigned long data, int bits) {
irSender.sendNEC(data, bits);
}
void loop() {
// Example: Send a custom 32-bit value
unsigned long data = 0x12345678;
int bits = 32;
sendIRSignal(data, bits);
// Test the IR receiver by checking for received signals
if (irReceiver.decode(&results)) {
Serial.print("Received Value: 0x");
Serial.println(results.value, HEX);
irReceiver.resume(); // Enable the receiver to receive the next signal
}
delay(1000); // Wait for 1 second before sending the next signal
}