IR remote and Arduino

ElectroBatool's picture


Joined: Aug 04, 2016

Replies: 0
IR remote and Arduino
August 4, 2016 - 10:07am

I want to know the codes for each button that I use for my (car mp3 remote control), I write the following programming code: 

#include <IRremote.h>

int Recv_Pin=8;

IRrecv irrecv(Recv_Pin);

decode_results results;

void setup() {
 Serial.begin (9600);

void loop() {
 if (irrecv.decode(&results)){
    Serial.println (results.value);

but when I upload it to the arduino board, it keeps giving the same code for different bottons. So is my code correct, and how to solve this problem and know the right code for each button ? 

Abhishek's picture


Joined: May 19, 2015

Replies: 403

You first need to decode output of all the remote buttons and then code them accordingly. 

If you don’t know the Decoded output for your IR remote, it can be easily found, just follow these steps:

  1. Download the IR remote library from here
  2. Unzip it, and place it in your Arduino ‘Libraries’ folder. Then rename the extracted folder to IRremote.
  3. Run the below program from your Arduino and open the Serial Monitor window in Arduino IDE. Now press any IR Remote button and see the corresponding decoded hex output in Serial Monitor window.
 * IRremote: IRrecvDemo - demonstrates receiving IR codes with IRrecv
 * An IR detector/demodulator must be connected to the input RECV_PIN.
 * Version 0.1 July, 2009
 * Copyright 2009 Ken Shirriff

#include <IRremote.h>
int RECV_PIN = 11;
IRrecv irrecv(RECV_PIN);
decode_results results;
void setup()
  irrecv.enableIRIn(); // Start the receiver
void loop() {
  if (irrecv.decode(&results)) {
    Serial.println(results.value, HEX);
    irrecv.resume(); // Receive the next value

For more information go through this project: IR Remote Controlled Home Automation using Arduino

Neal McDonald's picture


Joined: Jul 12, 2016

Replies: 8

Writing down the codes along with keeping a track of unknown codes can help in cracking the difficulties easily.