hi everyone
i recently brought a ir remote for arduino (B)
but when doing any projects the ir remote do not send any hex number but its working.
what to do?
Tell us what the device is , how it’s connected , code you’ve used ...
irremote black
gnd,5v,11
#include <IRremote.h>
int RECV_PIN = 11;
const char type ='B';// W for white, B for black. Must keep single quotes like 'B' or 'W'
const boolean PCB = 1;// if receiver is PCB set to 1, if not set to 0. See video for details
IRrecv irrecv(RECV_PIN);
// this is array holding codes for White Remote when used with PCB verion of receiver
unsigned int whiteRemotePCB[] ={
0xE318261B, // CH-
0x511DBB, // CH
0xEE886D7F, // CH+
0x52A3D41F, // |<<
0xD7E84B1B, // >>|
0x20FE4DBB, // >||
0xF076C13B, // -
0xA3C8EDDB, // +
0x12CEA6E6, // EQ
0xC101E57B, // 0
0x97483BFB, // 100+
0xF0C41643, // 200+
0x9716BE3F, // 1
0x3D9AE3F7, // 2
0x6182021B, // 3
0x8C22657B, // 4
0x488F3CBB, // 5
0x449E79F, // 6
0x32C6FDF7, // 7
0x1BC0157B, // 8
0x3EC3FC1B // 9
};
// this is array holding codes for White Remote when used with non-PCB verion of receiver
unsigned int whiteRemote[] ={
0xFFA25D, // CH-
0xFF629D, // CH
0xFFE21D, // CH+
0xFF22DD, // |<<
0xFF02FD, // >>|
0xFFC23D, // >||
0xFFE01F, // -
0xFFA857, // +
0xFF906F, // EQ
0xFF6897, // 0
0xFF9867, // 100+
0xFFB04F, // 200+
0xFF30CF, // 1
0xFF18E7, // 2
0xFF7A85, // 3
0xFF10EF, // 4
0xFF38C7, // 5
0xFF5AA5, // 6
0xFF42BD, // 7
0xFF4AB5, // 8
0xFF52AD // 9
};
// key lables of white remote
String whiteRemoteKey[] ={
"CH-",
"CH",
"CH+",
"|<<",
">>|",
">||",
"-",
"+",
"EQ",
"0",
"100+",
"200+",
"1",
"2",
"3",
"4",
"5",
"6",
"7",
"8",
"9"
};
// this is array holding codes for Black Remote when used with non-PCB verion of receiver
unsigned int blackRemote[] ={
0xFF629D, // ^
0xFF22DD, // <
0xFF02FD, // OK
0xFFC23D, // >
0xFFA857, // v
0xFF6897, // 1
0xFF9867, // 2
0xF0C41643, // 3
0xFF30CF, // 4
0xFF18E7, // 5
0xFF7A85, // 6
0xFF10EF, // 7
0xFF38C7, // 8
0xFF5AA5, // 9
0xFF42BD, // *
0xFF4AB5, // 0
0xFF52AD // #
};
// this is array holding codes for Black Remote when used with PCB verion of receiver
unsigned int blackRemotePCB[] ={
0x511DBB, // ^
0x52A3D41F, // <
0xD7E84B1B, // OK
0x20FE4DBB, // >
0xA3C8EDDB, // v
0xC101E57B, // 1
0x97483BFB, // 2
0xF0C41643, // 3
0x9716BE3F, // 4
0x3D9AE3F7, // 5
0x6182021B, // 6
0x8C22657B, // 7
0x488F3CBB, // 8
0x449E79F, // 9
0x32C6FDF7, // *
0x1BC0157B, // 0
0x3EC3FC1B // #
};
// Black remote key names
String blackRemoteKey[] ={
"^",
"<",
"OK",
">",
"v",
"1",
"2",
"3",
"4",
"5",
"6",
"7",
"8",
"9",
"*",
"0",
"#"
};
decode_results results;
void setup()
{
Serial.begin(9600);
// In case the interrupt driver crashes on setup, give a clue
// to the user what's going on.
Serial.println("Robojax Remote Decoder");
irrecv.enableIRIn(); // Start the receiver
}
void loop() {
if (irrecv.decode(&results)) {
//Serial.println(results.value, HEX);
robojaxValidateCode(results.value);// used the "robojaxValidateCode" bellow
irrecv.resume(); // Receive the next value
}
delay(100);
}
/*
* function: robojaxValidateCode
* validates the remote code and prints correct key name
* cd is code poassed from the loop
* Written by A. S. for Robojax
*/
void robojaxValidateCode(int cd)
{
// Robojax IR Remote decoder
int found=0;
if(type =='W' && !PCB)
{
// Robojax IR White Remote decoder
// if tyepe is set to 'W' (white remote) and PCB=0 then check Black remote code
for(int i=0; i< sizeof(whiteRemote)/sizeof(int); i++)
{
if(whiteRemote[i] ==cd)
{
Serial.print("Key pressed:");
Serial.println(whiteRemoteKey[i]);
found=1;
}// if matched
}// for
}else if(type =='W' && PCB){
// Robojax IR White Remote decoder
// if tyepe is set to 'W' (white remote) and PCB=1 then check Black remote code
for(int i=0; i< sizeof(whiteRemotePCB)/sizeof(int); i++)
{
if(whiteRemotePCB[i] ==cd)
{
Serial.print("Key pressed:");
Serial.println(whiteRemoteKey[i]);
found=1;
}// if matched
}// for
}else if(type =='B' && PCB){
// Robojax IR White Remote decoder
// if tyepe is set to 'B' (black remote) and PCB=1 then check Black remote code
for(int i=0; i< sizeof(blackRemotePCB)/sizeof(int); i++)
{
// Robojax IR black Remote decoder
if(blackRemotePCB[i] ==cd)
{
Serial.print("Key pressed:");
Serial.println(blackRemoteKey[i]);
found=1;
}// if matched
}// for
}else{
// if tyepe is set to 'B' (black remote) and PCB =0 then check Black remote code
for(int i=0; i< sizeof(blackRemote)/sizeof(int); i++)
{
// Robojax IR black Remote decoder
if(blackRemote[i] ==cd)
{
if(blackRemoteKey[i] == "OK"){
digitalWrite(9,HIGH);
}
Serial.print("Key pressed:");
Serial.println(blackRemoteKey[i]);
found=1;
}// if matched
}// for
}// else
if(!found){
if(cd !=0xFFFFFFFF)
{
Serial.println("Key unkown");
}
}// found
}
Isn’t this the code for receiving an IR signal and decoding it ? Therefore it sends nothing
well i tried some more codes and it did not work out
Are you saying, looking at your code, that you have two working remote control units, but the program cannot interpret the IR codes either of these units send ?
Question 1. From where did you get the hex codes example 0x8C22657B, // 7
Question 2. Why not run a simple sketch which simply prints out the codes it receives ?
Libraries usually have some example code , run that .
If this is an IR receiver (is it ?) then it’s physically unable to send data .
i used different codes for decoding too
but since it was copy and paste i had to delete and paste new codes on the same file
Is the sketch reporting "Key unknown" ?
yep it was
hi
i tried this code
#include <IRremote.h> //including infrared remote header file
int RECV_PIN = 7; // the pin where you connect the output pin of IR sensor
IRrecv irrecv(RECV_PIN);
decode_results results;
void setup()
{
Serial.begin(9600);
irrecv.enableIRIn();
}
void loop() {
if (irrecv.decode(&results))// Returns 0 if no data ready, 1 if data ready.
{
int readResults = results.value;// Results of decoding are stored in result.value
Serial.println(" ");
Serial.print("Code: ");
Serial.println(results.value); //prints the value a a button press
Serial.println(" ");
irrecv.resume(); // Restart the ISR state machine and Receive the next value
}
}
after i open the serial monitor it starts to show numbers randomly while im not pressing any button
What board did they write this sketch for? On an Arduino UNO, Nano, Mega... the 16-bit 'unsigned int' type can't hold those 32-bit numbers.
What version number of the IRremote library do you have installed?
Hi,
What are you using as the IR reciever?
Can you post a copy of your circuit please?
Can you please post picture(s) of your project so we can see your component layout?
How do you know the IR remote is working?
Thanks.. Tom...
For uno
The latest one
This also looks wrong. Try uint32_t instead of int.
The sketches you’ve posted have different receive pins.
I'm using the normal or receiver as shown in the circuit diagram
GitHub - Arduino-IRremote/Arduino-IRremote: Infrared remote library for Arduino: send and receive infrared signals with multiple protocols the link I downloaded the lib
It looks like that board has an RGB LED without series resistors.
Well I just used the connection for the receiver and not for the RGB led.(I do not not have any RGB led too )