Weekend project- DIY TV remote controlled car

Its pretty cool that we can control many appliances in our home wirelessly through IR systems. Perhaps is that all ? In this blog, ill be sharing an interesting use of the TV remote other than its conventional use of controlling the TV. 
So, you can make your own TV remote controlled car by following the video and the resources.
1.The video

2. The circuit diagram


DON'T FORGET TO POWER THE ARDUINO!!
3. Link for the IR remote library.

https://github.com/z3t0/Arduino-IRremote

4. List of main parts

  • An Arduino Uno,
  • DC motor shafts,
  • L293x motor driver,
  • TSOP 1738 IR receiver,
  • 9V battery,
  • Jumper wires( of-course)



5. And of-course the code for the arduino

// Written and debugged by Siddharth Kothari, monacrylic.blogspot.in
#include <IRremote.h>
int leftmotora=8;
int leftmotorb=9;
int rightmotora=10;
int rightmotorb=12;


int RECV_PIN = 11;

IRrecv irrecv(RECV_PIN);

decode_results results;

void setup(){
  irrecv.enableIRIn(); // start the receiver


  pinMode (11, INPUT); //pin 11 connects to the IR receiver (tsop1738)
  pinMode(8, OUTPUT);
  pinMode(9, OUTPUT);
  pinMode(10, OUTPUT);
  pinMode(12, OUTPUT);
}

void loop() {
  if (irrecv.decode(&results)) {

  if (results.value==0xE0E08679){ // When the forward button is pressed
   digitalWrite(leftmotora, LOW);
   digitalWrite(leftmotorb, HIGH);
   digitalWrite(rightmotora, LOW);
   digitalWrite(rightmotorb, HIGH);
    }
   if (results.value==0xE0E006F9){ //when the backward direction, button is pressed
   digitalWrite(leftmotora, HIGH);
   digitalWrite(leftmotorb, LOW);
   digitalWrite(rightmotora, HIGH);
   digitalWrite(rightmotorb, LOW);
    }
   if (results.value==0xE0E0A659){ //to turn left
   digitalWrite(leftmotora, HIGH);
   digitalWrite(leftmotorb, LOW);
   digitalWrite(rightmotora, LOW);
   digitalWrite(rightmotorb, HIGH);
    }

    if (results.value==0xE0E046B9){//to turn right
   digitalWrite(leftmotora, LOW);
   digitalWrite(leftmotorb, HIGH);
   digitalWrite(rightmotora, HIGH);
   digitalWrite(rightmotorb, LOW);
    }
   if (results.value==0xE0E016E9){//THE STOP BUTTON !!
   digitalWrite(leftmotora, LOW);
   digitalWrite(leftmotorb, LOW);
   digitalWrite(rightmotora, LOW);
   digitalWrite(rightmotorb, LOW);
    }


  irrecv.resume(); // get ready to receive the next signal
}}

Simply copy-paste this in your arduino IDE and upload it, ensure that you've change the hexadecimal values for the remote buttons as per your remote.
If your receiver doesn't read the value correctly (doesn't give the same value every time you press the button) try using a different remote.
Let the 0x in every if statement remain as it is, it is to declare that the datatype of the value ahead is hexadecimal. 
changes made in the hexadecimal value should follow this syntax-
if(results.value==0x<hexadecimal>)

If you're done with making this, and everything's working perfectly fine, you might want to add some more features, you can do that by simply adding more if statements following the syntax-


if (results.value==0xE0E016E9){
  //add whatever you want to, for example ,switch on an led
digitalWrite(13, HIGH);
    }

I'll leave the rest to you, let your creativity overwrite my code :)

Cheers 
Siddharth






Popular posts from this blog

Rubik's New Challenge -

Fender Squier Review