Harrison Murray
Published © CC0

IR Control with Arduino

Basic platform for controlling things with any remote control.

BeginnerWork in progress1 hour5,523
IR Control with Arduino

Things used in this project

Hardware components

Arduino UNO
Arduino UNO
×1
IR receiver (generic)
×1
LED (generic)
LED (generic)
×4
Jumper wires (generic)
Jumper wires (generic)
×11
Breadboard (generic)
Breadboard (generic)
×1
Resistor 221 ohm
Resistor 221 ohm
×4

Software apps and online services

Arduino IDE
Arduino IDE

Schematics

IR schematics

Code

IR remote control

Arduino
basic platform to control anything with any remote
#include <IRremote.h>
int RECV_PIN = 6;
int BLUE_LED = 13;
int RED_LED = 12;
int YELLOW_LED = 10;
int GREEN_LED = 11;


IRrecv irrecv(RECV_PIN);
decode_results results;

void setup() {                
  // initialize the digital pin as an output.
  pinMode(RECV_PIN, INPUT);  
  pinMode(BLUE_LED, OUTPUT); 
  pinMode(RED_LED, OUTPUT);
  pinMode(YELLOW_LED, OUTPUT); 
  pinMode(GREEN_LED, OUTPUT);
  irrecv.enableIRIn(); // Start the receiver
  Serial.begin(9600);
}
void loop() {
  int i=0;
   if (irrecv.decode(&results)) {
   
   translateIR();
   unknownRemoter();
      
     irrecv.resume(); // Receive the next value
    
   }   
 }

 void translateIR() // takes action based on IR code received describing Car MP3 IR codes 
{

  switch(results.value){
  case 0x20DFDA25:  
    Serial.println("LED off          "); 
    digitalWrite(13,LOW);
    digitalWrite(12,LOW); 
    digitalWrite(11,LOW);
    digitalWrite(10,LOW); 
    break;
  case 0x20DF4EB1:  
    Serial.println(" red LED on        "); 
    digitalWrite(12, HIGH);
    break;
  case 0x20DF8679:  
    Serial.println(" blue LED on        "); 
    digitalWrite(13, HIGH);
    break;  
  case 0x20DFC639:  
    Serial.println(" yellow LED on        "); 
    digitalWrite(10, HIGH);
    break;
  case 0x20DF8E71:  
    Serial.println(" green LED on        "); 
    digitalWrite(11, HIGH);
    break;

 

  default: 
    Serial.print(" unknown button   ");
    Serial.println(results.value, HEX);

  }

  delay(500);


} 
                  
void unknownRemoter(){                       //this function is from an old remoter see video.
long RED_LED_OFF = 0xFF40BF;
long RED_LED_ON =  0xFF906F;
long LAST_BUTTON = 0xFFD02F;

if (results.value == RED_LED_OFF){
      Serial.println ("Red led off");
      digitalWrite(12,LOW);
      }
     else if (results.value == RED_LED_ON )
      {
       Serial.println ("Red led on");
      digitalWrite(12,HIGH);
      }
     else if (results.value == LAST_BUTTON )
      {
       Serial.println ("CAMERA IMAGE button");
      }else{
         Serial.print(" still an unknown button   ");
         Serial.println(results.value, HEX);
        }
}

Credits

Harrison Murray

Harrison Murray

0 projects • 2 followers
A nerd with a passion for art and electronics!

Comments