Arduino uno R3 IRremote find the code sketch

I am looking for a sketch to see what button on the remote control has what code I have already tried 5 sketches and none works, can anyone help?

I am from Polish and I do not know English, so I use google translator for all indescribable words, sorry

File -> Examples -> IRremote -> ReceiveDump

also does not work

Hi, I am having the same issue as gzib. I am using a VS1838b IR receiver. There are many (older version) examples, many of which do not work, in part because they use the old IRremote library. I have tried using the example you suggested, but when connected to pin 2 (default receiver pin I think) the serial monitor just fills with seemingly random inputs. This happens regardless of any remote input (remote which came with kit, or TV remote). Could this be a hardware issue, or is there something that needs adapting in the code?

Is the Serial Monitor baud rate set to 115200? It has to match the sketch.

Yeah, it's set to 115200.

The output looks like this:

18:13:40.678 -> Protocol=UNKNOWN Hash=0x0 1 bits (incl. gap and start) received
18:13:40.678 ->
18:13:40.678 -> Raw result in internal ticks (50 us) - with leading gap
18:13:40.678 -> rawData[2]:
18:13:40.678 -> -238
18:13:40.678 -> + 141
18:13:40.678 -> Raw result in microseconds - with leading gap
18:13:40.678 -> rawData[2]:
18:13:40.678 -> -11900
18:13:40.678 -> +7050
18:13:40.678 ->
18:13:40.678 -> Result as internal ticks (50 us) array - compensated with MARK_EXCESS_MICROS=20
18:13:40.678 -> uint8_t rawTicks[1] = {141}; // Protocol=UNKNOWN Hash=0x0 1 bits (incl. gap and start) received
18:13:40.678 ->
18:13:40.678 -> Result as microseconds array - compensated with MARK_EXCESS_MICROS=20
18:13:40.678 -> uint16_t rawData[1] = {7030}; // Protocol=UNKNOWN Hash=0x0 1 bits (incl. gap and start) received
18:13:40.724 ->
18:13:40.724 -> Pronto Hex as string
18:13:40.724 -> char prontoData[] = "0000 006D 0001 0000 0110 06C3 ";

And then it repeats with new timestamps. I tested it on 2 boards, so maybe a wiring problem? I've tried different wiring options based on tutorials, but so far no luck getting it to receive signals.

Here is a simple sketch that I wrote to get the key code and address of the buttons on an IR remote. Also outputs the protocol. This uses the new version of the IRremote library. Note that the receive pin is set to pin 4 so change it if you need. And the baud rate is 115200. This code has been tested and proven to work on my Uno with a TSOP1838 type decoder.

#include <IRremote.hpp>

const byte IR_RECEIVE_PIN = 4;

unsigned long keycommand = 0;
unsigned long keyaddress = 0;
decode_type_t remoteprotocol;

bool newIR = false;

const char *thisProtocol[] = {"UNKNOWN", "PULSE_DISTANCE","PULSE_WIDTH","DENON","DISH","JVC","LG","LG2","NEC","PANASONIC",
                      "KASEIKYO","KASEIKYO_JVC","KASEIKYO_DENON","KASEIKYO_SHARP","KASEIKYO_MITSUBISHI","RC5","RC6",
                      "SAMSUNG","SHARP","SONY","ONKYO","APPLE","BOSEWAVE","LEGO_PF","MAGIQUEST","WHYNTER"};

void setup()
{
   Serial.begin(115200);
   Serial.println("IR receive test");
   IrReceiver.begin(IR_RECEIVE_PIN, ENABLE_LED_FEEDBACK);
}

void loop()
{
   checkIR();

   if (newIR)
   {
      printIR();
      newIR = false;
   }
}

void checkIR()
{
   if (IrReceiver.decode())
   {

      keycommand = IrReceiver.decodedIRData.command;
      keyaddress = IrReceiver.decodedIRData.address;
      remoteprotocol = IrReceiver.decodedIRData.protocol;

      if ((IrReceiver.decodedIRData.flags & IRDATA_FLAGS_IS_REPEAT))
      {
         IrReceiver.resume();
         return;
      }

      IrReceiver.resume();
      newIR = true;
   }
}

void printIR()
{
   Serial.print("decoded command = ");
   Serial.print(keycommand, HEX);
   Serial.print("     decoded address = ");
   Serial.print(keyaddress, HEX);
   Serial.print("     decoded protocol = ");
   Serial.println(thisProtocol[remoteprotocol]);
   Serial.println();
}

Output for the up and down arrows for 2 different remotes:

IR receive test
decoded command = 39 decoded address = 1C5A decoded protocol = SONY

decoded command = 3A decoded address = 1C5A decoded protocol = SONY

decoded command = 40 decoded address = 4 decoded protocol = NEC

decoded command = 41 decoded address = 4 decoded protocol = NEC

Unfortunately this code doesn't appear to work for me either. It must be I've wired something wrong somehow.

I've tried wiring like this:

and this:

With and without resistors. But no luck. I thought it was pretty straightforward to follow the wiring, as have also been playing about with LEDs and servos.

Wiring super simple. No resistor.

Or to the pin of your choice. Make sure the code reflects the pin number that you use.

Is there a chance that the power to the receiver/decoder could have been wired backwards at some point? That will kill one very quickly.

It may have been, I've tried different combinations as I've seen a few different pinouts for VS1838b. I did think I may have burn it out if I put the wires the wrong way (or without resistor, like LEDs). I'll order a new one (on a board this time, so its clearly labelled) and test the codes again. Thanks for your recommendations and help so far.

Update:
Your code works. Tested with a new receiver today and I'm getting some numbers for button presses. Now to work on the rest. Thanks for your help.

The forum limits new users to 3 replies, so I had to edit this.

I need a sketch to check the code of a button on the remote control

Post #7.

This topic was automatically closed 180 days after the last reply. New replies are no longer allowed.