Have you ever wondered that how it would be to control you toy or a robot using your TV/DVD or any IR Remote?

Then, this project will provide you the easy to follow tutorial on making your imagination a reality.

Here, you will learn to make a tv remote controlled bot  by using any kind of IR Remote. The knowledge gained in this project will benefit you in projects related to the use of universal IR Receiver with Arduino, Home automation projects and further you will be able to make any automation projects related to industries, Home, School or office.

Project Level: Intermediate

So,let’s get started !

Decoding Remote: Reading the button’s value:

Since, Arduino IDE comes with a remote library that will not work with this project, so you need to include this library (Click) in your Arduino IDE. And delete the library in the Arduino IDE previously i.e. having name similar to ”REMOTE.h”.

 Connection :

Code for Decoding Remote:

#include <IRremote.h>

int IRpin = 12;
IRrecv irrecv(IRpin);
decode_results results;


void setup()
{
  Serial.begin(9600);
  irrecv.enableIRIn(); // Start the receiver
}  
void loop() 

{   
  if (irrecv.decode(&results)) 
    {
     Serial.println(results.value); // Print the Serial 'results.value'
      delay(10);

     irrecv.resume();   // Receive the next value
    }
}

 

After uploading the above code, open the Serial Monitor and with ever press of the button you will find some code reflected on the serial monitor. Note down these codes corresponding to each button you want to use. Here, leave the codes that repeats whenever any button is pressed, since it is of no use.

Once, you have got the button hex-code decoded. You are now ready to control the relays with that remote.

Connection: For the bot

Code Section:

Here replace the hexcode(for example 16732845)with your own decoded button code.

#include <IRremote.h>

int RMotorF=3;
int RMotorB=4;
int LMotorF=5;
int LMotorB=6;
int IRpin = 12;  // pin for the IR Reciever
  
IRrecv irrecv(IRpin);
decode_results results;



void setup()
{
  Serial.begin(9600);
  irrecv.enableIRIn(); // Start the receiver
  
  pinMode(LMotorF,OUTPUT);
  pinMode(RMotorF,OUTPUT);
  pinMode(LMotorB,OUTPUT);
  pinMode(RMotorB,OUTPUT);

}

void loop() 
{
   
  if (irrecv.decode(&results)) 
    {
     Serial.println(results.value); // Print the Serial 'results.value'
      delay(10);

     irrecv.resume();   // Receive the next value
    }
  
if(results.value==16732845) //Here Replace the hexcode(16732845)with your own decoded button code
moveforward();
if(results.value==16742535) 
moveback();
if(results.value==16769565) 
stopbot();
if(results.value==16726215)
moveright();
if(results.value==16775175)
moveleft();

}
void moveforward()
  {
    digitalWrite(LMotorF,HIGH);
    digitalWrite(RMotorF,HIGH);
    digitalWrite(LMotorB,LOW);
    digitalWrite(RMotorB,LOW); 
    
   
    }
 
  void moveleft()
  {
  digitalWrite(RMotorF,HIGH);  
  digitalWrite(LMotorF,LOW);
  digitalWrite(LMotorB,HIGH);
   digitalWrite(RMotorB,LOW);
  }
  
  
  void moveright()
  {
    digitalWrite(LMotorF,HIGH); 
    digitalWrite(RMotorF,LOW);
    digitalWrite(LMotorB,LOW);
    digitalWrite(RMotorB,HIGH);
  }
  
  void moveback()
  {
    digitalWrite(LMotorB,HIGH);
    digitalWrite(RMotorB,HIGH);
    digitalWrite(LMotorF,LOW);
    digitalWrite(RMotorF,LOW);
  }
void stopbot()
{
    digitalWrite(LMotorB,LOW);
    digitalWrite(RMotorB,LOW);
    digitalWrite(LMotorF,LOW);
    digitalWrite(RMotorF,LOW);
}


 

SHARE
Previous articleArduino LED Cube 4X4X4
Next articleArduino GPS Module Interface

LEAVE A REPLY

Please enter your comment!
Please enter your name here