Simple CAR Arduino iR Controlled
In this project I will show you how to make a vehicle controlled by a TV remote control. for this we will use an infrared receiver. It will show you how to receive and decode the received button codes.
List element:
- iR Receiver
- Arduino uno
- L298N motor shield
- Plexi 17cm x 10cm
- 4x TT gear Motor
- 4x wheels
- Battery 9V
- Battery connector
- Wires
- Switch
Video Tutorial:
Schema:
Arduino to L298N:
- D8 to IN1
- D9 to IN2
- D10 to IN3
- D11 to IN4
- Vin to 5V
- GND to GND
iR Receiver to Arduino:
- Data to D7
- Vcc to 5V
- GND to GND

iR Decoder:
For the operation of our receiver, we need the Arduino-IRremote-master library.
- Download the library (Arduino_IRremote-master) :
- Open Arduino Ide
- Select : Sketch ->Include Library-> Add .ZIP Library-> select Arduino-IRremote-master.zip.


Now we will upload the sketch to our arduino and open Serial Monitor. Now use the TV’s remote control, point it at the receiver and press any button. In the serial monitor window you will see the button code.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 |
/* ForbiddenBit.com */ #include <IRremote.h> #define IRPIN 7 IRrecv irrecv(IRPIN); decode_results result; void setup() { Serial.begin(9600); irrecv.enableIRIn(); Serial.println("Enabled IRin"); } void loop(){ if (irrecv.decode(&result)) { Serial.println(result.value); irrecv.resume(); } } |

Now copy the button codes to the iR_Car.ino sketch .
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 |
/* ForbiddenBit.com */ #include <IRremote.h> #define irPin 7 IRrecv irrecv(irPin); decode_results results; void setup() { pinMode(8,OUTPUT); pinMode(9,OUTPUT); pinMode(10,OUTPUT); pinMode(11,OUTPUT); Serial.begin(9600); irrecv.enableIRIn(); } void loop() { if (irrecv.decode(&results)) { Serial.println(results.value); switch (results.value) { case 551504055: // button 2 FORDWARD forward(); break; case 551495895: // button 4 LEFT left(); break; case 551528535: // button 5 STOP Stop(); break; case 551512215: // button 6 RIGHT right(); break; case 553009523: // button 8 BACK back(); break; } irrecv.resume(); } } void forward() { digitalWrite(8, HIGH); digitalWrite(9, LOW); digitalWrite(10, HIGH); digitalWrite(11, LOW); } void back() { digitalWrite(8, LOW); digitalWrite(9, HIGH); digitalWrite(10, LOW); digitalWrite(11, HIGH); } void left() { digitalWrite(8, LOW); digitalWrite(9, HIGH); digitalWrite(10, HIGH); digitalWrite(11, LOW); } void right() { digitalWrite(8, HIGH); digitalWrite(9, LOW); digitalWrite(10, LOW); digitalWrite(11, HIGH); } void Stop() { digitalWrite(8, LOW); digitalWrite(9, LOW); digitalWrite(10, LOW); digitalWrite(11, LOW); } |