i got this code from my good freind: "chat-GPT". the idea was that i could recieve IR codes. but when i press a button on my remote it spits out random codes. here the code :
#include <IRremote.h>
IRrecv irrecv(4);
decode_results results;
void setup() {
Serial.begin(9600);
irrecv.enableIRIn();
}
void loop() {
if (irrecv.decode(&results)) {
Serial.println("Received IR signal:");
for (int i = 0; i < results.rawlen; i++) {
Serial.print(results.rawbuf[i] * USECPERTICK, DEC);
if (i % 2 == 1) {
Serial.print(" ");
}
}
Serial.println("");
irrecv.resume();
}
}
i wnated to re send the code via this script:
#define IRLED 3
#include <IRremote.h>
IRsend irsend;
unsigned int signal[] = {SIGNAL};
int signalLength = sizeof(signal) / sizeof(signal[0]);
void setup() {
Serial.begin(9600);
}
void loop() {
if (Serial.available() > 0) {
char input = Serial.read();
if (input == 's') {
irsend.sendRaw(signal, signalLength, 38);
}
}
}
i didn't want to use the "normal" method of doing this cuz i would have to deal with protecols. i want it to be automated so using protecols would be anoying cuz that would be hard to program automaticly. if ther is also a alternative way to send/recieve IR signals without protecols pls let me know (or if you know wy it spits out gabage)
Random values can be from the IR light from ambient, sun or light bulb.
i treid to make my room pitchblack and my plaptop on 10% brightnes and still having the same issue
Please edit your first post and put tags </> in your code.
Also show us your circuit.
It may be a special (protected, varying) protocol.
I think this resistor is not needed. Have you checked the datasheet of this receiver?
without it also does not work. but you ar richt it does not need to be there.
What you can get with example "ReceiveDump" from library?
Have you tested with another remote control?
J-M-L
January 27, 2023, 2:51pm
10
Did you ask the question to your good friend?
2 Likes
here what i get with the ReceiveDump example (i pressed the same button 3 times)
407F807F
Decoded NEC: 407F807F (32 bits)
Raw (68): 8950 -4400 600 -550 550 -1700 550 -500 600 -500 600 -550 600 -500 600 -500 600 -500 600 -550 600 -1600 600 -1650 550 -1650 600 -1650 550 -1650 600 -1650 550 -1650 600 -1650 550 -500 600 -500 600 -550 550 -550 600 -500 600 -500 600 -550 550 -550 600 -1600 600 -1650 600 -1600 600 -1650 550 -1650 600 -1650 550 -1650 600
407F807F
Decoded NEC: 407F807F (32 bits)
Raw (68): 8950 -4450 600 -500 600 -1600 600 -550 600 -500 600 -500 600 -500 600 -500 600 -550 600 -500 600 -1600 600 -1650 600 -1600 600 -1650 600 -1600 600 -1600 600 -1650 600 -1600 600 -550 550 -550 600 -500 600 -500 600 -500 600 -550 550 -550 600 -500 600 -1600 600 -1650 600 -1600 600 -1650 600 -1600 600 -1650 550 -1650 600
407F807F
Decoded NEC: 407F807F (32 bits)
Raw (68): 8950 -4450 600 -500 600 -1600 600 -550 600 -500 600 -500 600 -500 600 -500 600 -550 600 -500 600 -1600 600 -1650 600 -1600 600 -1650 550 -1650 600 -1600 600 -1650 600 -1600 600 -550 600 -500 600 -500 600 -500 600 -500 600 -550 550 -550 600 -500 600 -1600 600 -1650 600 -1600 600 -1650 600 -1600 600 -1650 550 -1650 600
and here the same with another remote (also 3 times)
C1AA09F6
Decoded NEC: C1AA09F6 (32 bits)
Raw (68): 9000 -4500 550 -1650 600 -1650 550 -600 600 -550 550 -550 600 -550 550 -550 550 -1700 600 -1650 600 -550 600 -1650 600 -550 500 -1750 600 -550 550 -1700 600 -500 600 -550 550 -600 550 -550 600 -550 550 -1650 600 -550 600 -550 550 -1650 600 -1700 600 -1650 600 -1600 600 -1650 600 -600 550 -1650 600 -1650 600 -550 550
C1AA09F6
Decoded NEC: C1AA09F6 (32 bits)
Raw (68): 9050 -4450 600 -1650 600 -1600 600 -600 550 -550 600 -550 550 -550 600 -550 500 -1700 600 -1700 600 -550 550 -1700 600 -500 550 -1700 600 -550 600 -1650 600 -550 550 -550 600 -550 600 -550 550 -550 600 -1650 600 -550 550 -550 550 -1700 600 -1650 600 -1650 600 -1650 550 -1700 600 -550 550 -1650 600 -1650 600 -550 550
C1AA09F6
Decoded NEC: C1AA09F6 (32 bits)
Raw (68): 9050 -4500 600 -1650 550 -1650 600 -550 600 -550 550 -600 550 -550 600 -500 550 -1700 600 -1650 600 -600 550 -1650 600 -550 550 -1700 600 -550 550 -1700 600 -550 550 -550 600 -550 550 -550 600 -550 550 -1650 600 -550 600 -550 550 -1700 600 -1650 600 -1650 600 -1600 600 -1700 600 -550 550 -1650 600 -1650 600 -550 550
As indicated by @DrDiettrich in post #5 , there are remotes that send different codes, even when the same button is pressed. Is that what you're observing?
Which remote do you use?
idual one
and the 2nd remote was for the epson eb x8 projector
What clearly states the exactly same code is received for each button press.
You want to get the Decoded value, not the uninterpreted Raw codes.
I can't see any problem here.
i want the raw data and that is different
It doesn't means that there's random codes.
Just use the right example to get the data.
i wnat to get the raw data and send it via the sendRaw() command
Instead ask to chatGPT write the code for you without know evaluate the result, use examples available in the library.
jorik_v_m:
i want the raw data
Then write your own version of the IRremote library that decodes the raw data as you want.