Arduino IR signals to turn on Sony TV

Hello everyone, I hope your smmer is going great. I was bored on a previous afternoon and as someone who has a whole arduino kit i thought I should put my Engineering degree to work so i can occupy my time. The project I am embarking on involves me sending IR signals mimicing the ON/OFF code of the SONY bravia tv model kdl-32m3000 which is a pretty old flat screen model.

I made sure the circuitry of my miniboard is wired properly (including a 220 ohm resistor, IR LED operating at 940 nm wavelength). To verify functionality I turned off the lights in my room and directed my phone camera at the LED. With my phone camera I was able to see the purple light from the LED transmitting the code so it was working.

The TV was still not coming on so I added 2 more LEDs in parallel to enhance signal strength but still no avail. My well commented code is below along with the SONY codes I tried so you can take a peak.

#include <IRremote.h>

const int irPin = 3; // My pin for the IR LED transmission
// I intentionally chose a pin for PWM since the SONY encoding scheme is based on PWM (.eg width of 2ns followed by 1ns = 0, 2ns followed by 3ns = 1
IRsend irsend; // Create an IRsend object

// Sony power ON/OFF code (12-bit Sony protocol)
unsigned long sonyPowerOffCodes[] = {
  0xA90UL,  // Common power ON/OFF code for Sony TVs
  0x290UL,  // Another Sony power ON/OFF code 
  0x490UL   // Yet another Sony power ON/OFF code
};

int numCodes = sizeof(sonyPowerOffCodes) / sizeof(sonyPowerOffCodes[0]);

void setup() {
  Serial.begin(9600);
  irsend.begin(irPin); // Initialize the IRsend library with the specified pin
  Serial.println("IR Remote Test Initialized");
}

void loop() {
  Serial.println("Starting send cycle...");
  for (int i = 0; i < numCodes; i++) {
    Serial.print("Sending code: 0x");
    Serial.println(sonyPowerOffCodes[i], HEX);
    // Send the same code multiple times to ensure reception
    for (int j = 0; j < 3; j++) { // Sending each code 3 times for trial
      irsend.sendSony(sonyPowerOffCodes[i], 0, 12); // Send Sony code with the updated function signature
      delay(50); // Short delay between repeats so there is no overload
    }
  }
  Serial.println("Send cycle complete.");
  delay(5000); // Waiting 5 seconds before repeating the sending cycle
}

Yes I was close enoughto the TV incase anyone is thinking about that :slight_smile:

Is your code right? Dronebotworkshop explains...