roshan-baig
Published © GPL3+

Arduino IR remote controlled Car

This car uses an ir sensor to control motors

AdvancedShowcase (no instructions)1,539
Arduino IR remote controlled Car

Things used in this project

Hardware components

Arduino UNO
Arduino UNO
×1
LED Light Bulb, Frosted GLS
LED Light Bulb, Frosted GLS
×2
Dual H-Bridge motor drivers L293D
Texas Instruments Dual H-Bridge motor drivers L293D
×1
5 mm LED: Red
5 mm LED: Red
×2
Through Hole Resistor, 1 kohm
Through Hole Resistor, 1 kohm
×2
IR receiver (generic)
×1
IR remote(generic)
×1
DC Motor, Miniature
DC Motor, Miniature
×1

Software apps and online services

Arduino IDE
Arduino IDE

Story

Read more

Schematics

This is the circuit diagram

Just follow this it won't steer you wrong

Code

the code

C/C++
please note that your IR remote will have different codes. please go to the link below to find out what they are.
https://www.tinkercad.com/things/8gxZInO9K6l
also there is a conflicting library called robot IR remote you MUST uninstall this for this code to work. also you need to install the IR remote library
#include <IRremote.h>
int receiver = 12;
int speed = 100;
IRrecv irrcev(receiver);
decode_results results;
void setup()
{
  pinMode(6, OUTPUT);
  pinMode(5, OUTPUT);
  pinMode(3, OUTPUT);
  pinMode(2, OUTPUT);
  pinMode(9, OUTPUT);
  pinMode(8, OUTPUT);
  pinMode(A0, OUTPUT);
  irrcev.enableIRIn();
}

void loop()
{
 if(irrcev.decode(&results))
 {
   irrcev.resume();
 }
  if(results.value == 16613503)
  {
    move_forward();
  }
  if(irrcev.decode(&results))
 {
   irrcev.resume();
 }
 if(results.value == 16621663)
  {
    stop();
  }
  if(irrcev.decode(&results))
 {
   irrcev.resume();
 }
   if(results.value == 16617583)
  {
    move_back();
  }
 if(irrcev.decode(&results))
 {
   irrcev.resume();
 }
 if(results.value == 16589023)
  {
    turn_left();
  }
 if(irrcev.decode(&results))
 {
   irrcev.resume();
 }
 if(results.value == 16605343)
  {
    turn_right();
 }
 if(irrcev.decode(&results))
 {
   irrcev.resume();
 }
 if(results.value == 16580863)
  {
    headlights();
 }
  if(irrcev.decode(&results))
 {
   irrcev.resume();
 }
  if(results.value == 16597183)
  {
    taillights();
 }
}
void move_forward()
{
  digitalWrite(5, LOW);
  digitalWrite(2, LOW);
  digitalWrite(6, HIGH);
  digitalWrite(3, HIGH);
}
void turn_right()
{
  digitalWrite(5, LOW);
  digitalWrite(3, LOW);
  digitalWrite(2, LOW);
  digitalWrite(6, HIGH);
}
void turn_left()
{
  digitalWrite(5, LOW);
  digitalWrite(6, LOW);
  digitalWrite(2, LOW);
  digitalWrite(3, HIGH);
}
void move_back()
{
  digitalWrite(6, LOW);
  digitalWrite(3, LOW);
  digitalWrite(5, HIGH);
  digitalWrite(2, HIGH);
}
void stop()
{
  digitalWrite(5, LOW);
  digitalWrite(2, LOW);
  digitalWrite(6, LOW);
  digitalWrite(3, LOW);
  digitalWrite(8, LOW);
  digitalWrite(9, LOW);
}
void headlights()
{
  digitalWrite(9, HIGH);
}
void taillights()
{
  digitalWrite(8, HIGH);
}

Credits

roshan-baig
5 projects • 7 followers

Comments