Ingo Lohs
Published © GPL3+

First Test: Super StarterKit from Elegoo - Infrared

This explains my short experience with infrared sensors.

BeginnerProtip1 hour13,347
First Test: Super StarterKit from Elegoo - Infrared

Things used in this project

Hardware components

Elegoo Infrared Sensor
its a part from a set
×1
Arduino UNO
Arduino UNO
×1
Jumper wires (generic)
Jumper wires (generic)
×1

Software apps and online services

Arduino Web Editor
Arduino Web Editor

Story

Read more

Code

Original Example Code from Elegoo

C/C++
// IRremote - Version: Latest 
#include <IRremote.h>
#include <IRremoteInt.h>

int receiver = 11; // Signal Pin of IR receiver to Arduino Digital Pin 11

/*-----( Declare objects )-----*/
IRrecv irrecv(receiver);     // create instance of 'irrecv'
decode_results results;      // create instance of 'decode_results'

void setup()   /*----( SETUP: RUNS ONCE )----*/
{
  Serial.begin(9600);
  Serial.println("IR Receiver Button Decode"); 
  irrecv.enableIRIn(); // Start the receiver

}/*--(end setup )---*/


void loop()   /*----( LOOP: RUNS CONSTANTLY )----*/
{
  if (irrecv.decode(&results)) // have we received an IR signal?

  {
    translateIR(); 
    irrecv.resume(); // receive the next value
  }  
}/* --(end main loop )-- */

/*-----( Function )-----*/
void translateIR() // takes action based on IR code received

// describing Remote IR codes 

{

  switch(results.value)
    
  {
  case 0xFFA25D: Serial.println("POWER"); break;
  case 0xFFE21D: Serial.println("FUNC/STOP"); break;
  case 0xFF629D: Serial.println("VOL+"); break;
  case 0xFF22DD: Serial.println("FAST BACK");    break;
  case 0xFF02FD: Serial.println("PAUSE");    break;
  case 0xFFC23D: Serial.println("FAST FORWARD");   break;
  case 0xFFE01F: Serial.println("DOWN");    break;
  case 0xFFA857: Serial.println("VOL-");    break;
  case 0xFF906F: Serial.println("UP");    break;
  case 0xFF9867: Serial.println("EQ");    break;
  case 0xFFB04F: Serial.println("ST/REPT");    break;
  case 0xFF6897: Serial.println("0");    break;
  case 0xFF30CF: Serial.println("1");    break;
  case 0xFF18E7: Serial.println("2");    break;
  case 0xFF7A85: Serial.println("3");    break;
  case 0xFF10EF: Serial.println("4");    break;
  case 0xFF38C7: Serial.println("5");    break;
  case 0xFF5AA5: Serial.println("6");    break;
  case 0xFF42BD: Serial.println("7");    break;
  case 0xFF4AB5: Serial.println("8");    break;
  case 0xFF52AD: Serial.println("9");    break;
  case 0xFFFFFFFF: Serial.println(" REPEAT");break;  

  default: 
    Serial.println(" other button   ");

  }// End Case

  delay(500); // Do not get immediate repeat


} //END translateIR

Update v1.1

C/C++
Serial.println(results.value); // > here you get the integer from your Remote
// IRremote - Version: Latest 
#include <IRremote.h>
#include <IRremoteInt.h>

int receiver = 11; // Signal Pin of IR receiver to Arduino Digital Pin 11

/*-----( Declare objects )-----*/
IRrecv irrecv(receiver);     // create instance of 'irrecv'
decode_results results;      // create instance of 'decode_results'

void setup()   /*----( SETUP: RUNS ONCE )----*/
{
  Serial.begin(9600);
  Serial.println("IR Receiver Button Decode"); 
  irrecv.enableIRIn(); // Start the receiver

}/*--(end setup )---*/


void loop()   /*----( LOOP: RUNS CONSTANTLY )----*/
{
  if (irrecv.decode(&results)) // have we received an IR signal?
  {
    Serial.println(results.value); // > here you get the integer from your Remote
    // use an Decimal to Hexadecimal Converter to get the Hex like this: http://www.binaryhexconverter.com/decimal-to-hex-converter
    // add your Mapping in the function translateIR > check the two examples with Power and number 5-Button
    translateIR(); 
    irrecv.resume(); // receive the next value
  }  
}/* --(end main loop )-- */

/*-----( Function )-----*/
void translateIR() // takes action based on IR code received

// describing Remote IR codes 

{

  switch(results.value)
    
  {
  case 0xFFA25D: Serial.println("POWER Elegoo"); break;     // 16753245 Elegoo
  case 0xE0E040BF: Serial.println("POWER Samsung"); break;  // 3772793023 Samsung
  case 0xD5AD0B51: Serial.println("POWER Technics"); break;  // 3584887633 Technics
  case 0xFFE21D: Serial.println("FUNC/STOP"); break;
  case 0xFF629D: Serial.println("VOL+"); break;
  case 0xFF22DD: Serial.println("FAST BACK");    break;
  case 0xFF02FD: Serial.println("PAUSE");    break;
  case 0xFFC23D: Serial.println("FAST FORWARD");   break;
  case 0xFFE01F: Serial.println("DOWN");    break;
  case 0xFFA857: Serial.println("VOL-");    break;
  case 0xFF906F: Serial.println("UP");    break;
  case 0xFF9867: Serial.println("EQ");    break;
  case 0xFFB04F: Serial.println("ST/REPT");    break;
  case 0xFF6897: Serial.println("0");    break;
  case 0xFF30CF: Serial.println("1");    break;
  case 0xFF18E7: Serial.println("2");    break;
  case 0xFF7A85: Serial.println("3");    break;
  case 0xFF10EF: Serial.println("4");    break;
  case 0xFF38C7: Serial.println("5 Elegoo");    break;     // 16726215 Elegoo
  case 0xE0E0906F: Serial.println("5 Samsung");    break;  // 3772813423 Samsung
  case 0xB1CE824B: Serial.println("5 Technics");    break;  // 2983101003 Technics
  case 0xFF5AA5: Serial.println("6");    break;
  case 0xFF42BD: Serial.println("7");    break;
  case 0xFF4AB5: Serial.println("8");    break;
  case 0xFF52AD: Serial.println("9");    break;
  case 0xFFFFFFFF: Serial.println(" REPEAT");break;  

  default: 
    Serial.println(" other button   ");

  }// End Case

  delay(500); // Do not get immediate repeat


} //END translateIR

Update v1.2

C/C++
// IRremote - Version: Latest 
#include <IRremote.h>
#include <IRremoteInt.h>

int receiver = 11; // Signal Pin of IR receiver to Arduino Digital Pin 11

/*-----( Declare objects )-----*/
IRrecv irrecv(receiver);     // create instance of 'irrecv'
decode_results results;      // create instance of 'decode_results'

void setup()   /*----( SETUP: RUNS ONCE )----*/
{
  Serial.begin(9600);
  Serial.println("IR Receiver Button Decode"); 
  irrecv.enableIRIn(); // Start the receiver

}/*--(end setup )---*/


void loop()   /*----( LOOP: RUNS CONSTANTLY )----*/
{
  if (irrecv.decode(&results)) // have we received an IR signal?
  {
    Serial.println(results.value); // > here you get the integer from your Remote
    // use an Decimal to Hexadecimal Converter to get the Hex like this: http://www.binaryhexconverter.com/decimal-to-hex-converter
    // add your Mapping in the function translateIR > check the two examples with Power and number 5-Button
    translateIR(); 
    irrecv.resume(); // receive the next value
  }  
}/* --(end main loop )-- */

/*-----( Function )-----*/
void translateIR() // takes action based on IR code received

// describing Remote IR codes 

{

  switch(results.value)
    
  {
  case 0xFFA25D: Serial.println("POWER Elegoo"); break;     // 16753245 Elegoo
  case 0xE0E040BF: Serial.println("POWER Samsung"); break;  // 3772793023 Samsung
  case 0xD5AD0B51: Serial.println("POWER Technics"); break;  // 3584887633 Technics
  case 0xA0C: Serial.println("POWER TechniSat"); break; // TechniSat
  
  case 0xFFE21D: Serial.println("FUNC/STOP"); break;
  case 0xFF629D: Serial.println("VOL+"); break;
  case 0xFF22DD: Serial.println("FAST BACK");    break;
  case 0xFF02FD: Serial.println("PAUSE");    break;
  case 0xFFC23D: Serial.println("FAST FORWARD");   break;
  case 0xFFE01F: Serial.println("DOWN");    break;
  case 0xFFA857: Serial.println("VOL-");    break;
  case 0xFF906F: Serial.println("UP");    break;
  case 0xFF9867: Serial.println("EQ");    break;
  case 0xFFB04F: Serial.println("ST/REPT");    break;
  
  case 0xFF6897: Serial.println("0");    break;
  case 0x200: Serial.println("0 TechniSat"); break; // TechniSat
  case 0xA00: Serial.println("0 TechniSat"); break; // TechniSat
  
  case 0xFF30CF: Serial.println("1");    break;
  case 0x201: Serial.println("1 TechniSat"); break; // TechniSat
  case 0xA01: Serial.println("1 TechniSat"); break; // TechniSat
  
  case 0xFF18E7: Serial.println("2");    break;
  case 0x202: Serial.println("2 TechniSat"); break; // TechniSat
  case 0xA02: Serial.println("2 TechniSat"); break; // TechniSat
  
  case 0xFF7A85: Serial.println("3");    break;
  case 0x203: Serial.println("3 TechniSat"); break; // TechniSat
  case 0xA03: Serial.println("3 TechniSat"); break; // TechniSat
  
  case 0xFF10EF: Serial.println("4");    break;
  case 0x204: Serial.println("4 TechniSat"); break; // TechniSat
  case 0xA04: Serial.println("4 TechniSat"); break; // TechniSat
  
  case 0xFF38C7: Serial.println("5 Elegoo");    break;     // 16726215 Elegoo
  case 0xE0E0906F: Serial.println("5 Samsung");    break;  // 3772813423 Samsung
  case 0xB1CE824B: Serial.println("5 Technics");    break;  // 2983101003 Technics
  case 0x205: Serial.println("5 TechniSat"); break; // TechniSat
  case 0xA05: Serial.println("5 TechniSat"); break; // TechniSat
  
  case 0xFF5AA5: Serial.println("6");    break;
  case 0x206: Serial.println("6 TechniSat"); break; // TechniSat
  case 0xA06: Serial.println("6 TechniSat"); break; // TechniSat
  
  case 0xFF42BD: Serial.println("7");    break;
  case 0x207: Serial.println("7 TechniSat"); break; // TechniSat
  case 0xA07: Serial.println("7 TechniSat"); break; // TechniSat

  case 0xFF4AB5: Serial.println("8");    break;
  case 0x208: Serial.println("8 TechniSat"); break; // TechniSat
  case 0xA08: Serial.println("8 TechniSat"); break; // TechniSat
  
  case 0xFF52AD: Serial.println("9");    break;
  case 0x209: Serial.println("9 TechniSat"); break; // TechniSat
  case 0xA09: Serial.println("9 TechniSat"); break; // TechniSat
  
  case 0xFFFFFFFF: Serial.println(" REPEAT");break;  

  default: 
    Serial.println(" other button   ");

  }// End Case

  delay(500); // Do not get immediate repeat


} //END translateIR

Update v1.1

Credits

Ingo Lohs

Ingo Lohs

182 projects • 194 followers
I am well over 50 years and come from the middle of Germany.

Comments