2

I am trying to switch the TV on using Arduino. Following is my set of code

#include <IRremote.h>

IRrecv receiver(2);
IRsend sender;
decode_results results;

long repeatitions;
long count;
unsigned int durations[100];
void (*reset)(void) = 0;

void setup() {
  Serial.begin(9600);
  receiver.enableIRIn();
}

void loop() {
  if (Serial.available()) {
    repeatitions = Serial.parseInt();
    count = Serial.parseInt();
    for (int i =0; i < repeatitions; i++) {
      durations[i] = Serial.parseInt();
    }
    for (int i = 0; i < repeatitions; i++) {
      Serial.println("sending code");
      sender.sendRaw(durations, count, 40);
      delay(50);
    }
    reset();
  }
  if (receiver.decode(&results)) {
    Serial.println(results.value, HEX);
    Serial.print(results.rawlen - 1);
    for (int i =1; i <results.rawlen;i++) {
      unsigned int number = results.rawbuf[i] * USECPERTICK;
      Serial.print(",");
      Serial.print(number);
    }
    Serial.println("");
    receiver.resume();
  }
}

The code receiving part works fine. And it returned me following code:

A90
25,2400,600,1200,600,600,550,1200,600,600,600,1200,600,600,600,550,600,1200,600,600,600,600,550,650,600,600

But when I try to use the same code to switch the TV on after adding durations to the above returned code it doesn't work. I am entering following into the serial monitor

3,25,2400,600,1200,600,600,550,1200,600,600,600,1200,600,600,600,550,600,1200,600,600,600,600,550,650,600,600

I have attached a screenshot to show how I have installed the IR Transmitter LED. enter image description here

I have two IR Transmitters. I have tried installing both in same manner 1 by 1. But unfortunately no success.

I am using IRRemote library by Shirriff https://github.com/z3t0/Arduino-IRremote

6
  • 1
    Where's your resistor? Commented Sep 24, 2017 at 10:25
  • This seems unlikely to work for many reasons. Presumably you are following some guide but have gone somewhat astray, you need to include a link to that and the exact IR library you are using in the question. In addition to the LED electrical issues (generally a transistor and series resistor are needed), pin 12 doesn't seem to be a usual output for IR sending on an ATmega328p - rather, it is usually pin 3 or 9. Commented Sep 24, 2017 at 18:25
  • I thought when using IR LED bulb the resistor wasn't required so I didn't include that in the circuit. Can you kindly share some circuit diagram that I should use in order to make the circuit work? Thanks Commented Sep 25, 2017 at 4:13
  • This would be in the instructions for whatever library you are using - I'd point out again that you have failed to identify which one you are using. Commented Sep 25, 2017 at 6:31
  • 1
    is the LED actually lighting up? use your smartphone camera to see IR light Commented Jan 17, 2018 at 5:18

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.