VISHAL SIVARAMAN
Published © GPL3+

IR - Remote Control Car

It is the next generation of remote control cars where signal attenuation is completely out of the picture.

IntermediateProtip5 hours8,488
IR - Remote Control Car

Things used in this project

Hardware components

Arduino UNO
Arduino UNO
×1
Dual H-Bridge motor drivers L298
SparkFun Dual H-Bridge motor drivers L298
×1
Breadboard (generic)
Breadboard (generic)
×1
3 wheel chasis
×1
ir reciver tsop1738
×1
12 volt battery holder for AA
×1
rechargable AA bateries
×1
Battery, 9 V
Battery, 9 V
×1
9 volt battery connector with dc power jack
×1
Jumper wires (generic)
Jumper wires (generic)
×1

Software apps and online services

Arduino IDE
Arduino IDE

Hand tools and fabrication machines

soldering iron
Solder Wire, Lead Free
Solder Wire, Lead Free
glue gun

Story

Read more

Schematics

block diagram of ir car

check the block diagram below for the connections

Code

ir reciever car main code

C/C++
before this follow the steps to finding out the equivalent hexadecimal values for 5 different buttons in remote and then we copy those different values and paste it in this code below for its equivalent function
#include <IRremote.h>   // including the IR remote library
#define forward  58359 // code received from forward  button
#define backward  5499  // code received from backward button
#define left  25979 // code received from left button
#define right  59295 // code received from right button
#define stop_button  15547 // code received from stop button
// Pins for first motor
int EN_A = 13;
int IN_1 = 12;
int IN_2 = 11;
// Pins for second motor
int EN_B = 8;
int IN_3 = 10;
int IN_4 = 9;
char command;
int receiver_pin = 4;   //Connect the output pin of IR receiver at pin 4
int vcc = 5;            //VCC for IR sensor
int gnd = 6;            //GND for IR sensor
IRrecv receiver(receiver_pin); //Arduino will take output of IR receiver from pin 2
decode_results output;
void setup()
{
  Serial.begin(9600);
  receiver.enableIRIn();  // Start to take the output from IR receiver
  //initializing all the pins as output pins
  pinMode(vcc, OUTPUT);
  pinMode(gnd, OUTPUT);
  pinMode(EN_A, OUTPUT);
  pinMode(EN_B, OUTPUT);
  pinMode(IN_1, OUTPUT);
  pinMode(IN_2, OUTPUT);
  pinMode(IN_3, OUTPUT);
  pinMode(IN_4, OUTPUT);
  
// Initializing ENA, ENB and vcc pin high
  digitalWrite(vcc, HIGH);
  digitalWrite(EN_A, HIGH);
  digitalWrite(EN_B, HIGH);
}
void loop() {
  if (receiver.decode(&output)) {
    unsigned int value = output.value;
    switch(value) {
     
  case forward:
      //Moving Forward
  digitalWrite(IN_1, HIGH);
  digitalWrite(IN_2, LOW); 
  digitalWrite(IN_3, LOW);
  digitalWrite(IN_4, HIGH);
          break;
       
case backward:
      //Moving backward
  digitalWrite(IN_1, LOW);
  digitalWrite(IN_2, HIGH); 
  digitalWrite(IN_3, HIGH);
  digitalWrite(IN_4, LOW);
         break;
       
case left:
       //Turning left
  digitalWrite(IN_3, LOW);
  digitalWrite(IN_4, HIGH);
          break;  
        
  case right:
        //Turning Right
  digitalWrite(IN_1, HIGH);
  digitalWrite(IN_2, LOW);
          break;
       
  case stop_button:
        //Stop
  digitalWrite(IN_1, LOW);
  digitalWrite(IN_2, LOW); 
  digitalWrite(IN_3, LOW);
  digitalWrite(IN_4, LOW);
          break;
}
    Serial.println(value);
    receiver.resume();
}
}

remote controls decoding code

C/C++
first we copy the below code and paste it in arduino IDE software and thenwe connect the ir reciever to the 6th pin of arduino and then we upload this code and run it ,then open serial monitor and for each button you press on the remote we can see its equivalent hexadecimal code and we have repeat the same for 5 different buttons(forward,backward ,left ,right ,stop) and then copy those different hexadecimal codes and paste it the main code for its equivalent function
#include <IRremote.h>

int RECV_PIN = 6;//pin 6 of arduino to data pin of ir receiver
IRrecv irrecv(RECV_PIN);
decode_results results;

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

void loop()
{
  if (irrecv.decode(&results))
    {
     Serial.println(results.value, HEX);
     irrecv.resume(); // Receive the next value
          delay(1000);

    }
}

Credits

VISHAL SIVARAMAN

VISHAL SIVARAMAN

3 projects • 1 follower

Comments