Go Down

Topic: IR Led (Read 113 times) previous topic - next topic

Munchnet

Apr 19, 2018, 12:46 pm Last Edit: Apr 19, 2018, 12:51 pm by Munchnet
Hi,

I have a project where I need to control a LED strip via IR.
What I have done so far is read the IR signals from the remote control using this code:

Code: [Select]

#include <IRremote.h>

const int RECV_PIN = 2;

IRrecv irrecv(RECV_PIN);

decode_results results;

void setup()
{
  Serial.begin(9600);
  irrecv.enableIRIn(); // Start the receiver
  irrecv.blink13(true);
}

void loop() {
  if (irrecv.decode(&results)) {
    if (results.decode_type == NEC) {
      Serial.print("NEC: ");
    } else if (results.decode_type == SONY) {
      Serial.print("SONY: ");
    } else if (results.decode_type == RC5) {
      Serial.print("RC5: ");
    } else if (results.decode_type == RC6) {
      Serial.print("RC6: ");
    } else if (results.decode_type == UNKNOWN) {
      Serial.print("UNKNOWN: ");
    }
    Serial.println(results.value, HEX);
    irrecv.resume(); // Receive the next value
  }
}


On the serial monitor I could clearly see input.
This is an example:

NEC: F7A857
NEC: FFFFFFFF
NEC: F7609F
NEC: FFFFFFFF
NEC: F750AF
NEC: FFFFFFFF

It looks like each time it received a code like NEC: F750AF
Then followed by NEC: FFFFFFFF

Initially I figured NEC: FFFFFFFF might just be an error.

So I tried sending the IR signal using:

Code: [Select]

#include <IRremote.h>

IRsend irsend;

void setup()
{
}

void loop() {
 for (int i = 0; i < 3; i++) {
 irsend.sendNEC(0xF750AF, 32);
 delay(40);
 }
 delay(5000); //5 second delay between each signal burst
}


But the LED strip didnt change colour.
Then I changed it a bit so it also sends the 0xFFFFFFFF

Code: [Select]

 for (int i = 0; i < 3; i++) {
 irsend.sendNEC(0xF750AF, 32);
 delay(10);
                irsend.sendNEC(0xFFFFFFFF, 32);
 delay(40);
 }


This is also not working.
I tried changing 32 bit to I think any possible number but it just wont change colour.
And yes, I know I revieved F750AF when I pressed the button for pink, so I changed the LED strip colour before sending it.

I am not quite new to this.
Any suggestions that may help ?

I am using a IR reciever and a IR Led that are on a small board.
I know the IR signal wire is going to the correct pin on the arduino.
I can see the IR LED flash when I look trough my phone's camera on it. (if that makes sense)

Munchnet

## Solved

On my 2nd arduino (Wemos D1 R2) the IRremote wouldnt be installed.
Found the IRremoteESP8266 library and got it working.
Using 2 arduino's one to read the IR signal and one to send it asily debug the issue.

In the end I think I didnt try it without sending 0xFFFFFFFF at 32
Just sending only:

irsend.sendNEC(0xF750AF, 32);

worked just fine.

sterretje

0xFFFFFFFF might indicate that it's a repeat of the previous code. In that case, if you keep one button pressed for a longer time (e.g. 10 seconds), you will e.g. get NEC: F7A857 followed by a long list of NEC: FFFFFFFF.

You can play with it if needed :)
If you understand an example, use it.
If you don't understand an example, don't use it.

Electronics engineer by trade, software engineer by profession. Trying to get back into electronics after 15 years absence.

Go Up