# IR remote controlled robot car with an Arduino: design worksheet and code

> A ₹1,570 design worksheet for driving a robot car with a TV-style infrared remote, with the NEC signal timing, a code-learning step and a stop-on-silence safety rule.

Canonical: https://roboticsengineering.in/projects/ir-remote-controlled-robot-car-arduino/ | Published: 2026-11-04 | Updated: 2026-11-04

**A ₹1,570 robot car you drive with a spare infrared remote. A three-pin receiver on the Arduino decodes the remote’s signal, the sketch maps each button to a motion, and the car stops by itself when the signal stops, so it never keeps running after you let go.**

**Scope:** beginner. This is a design worksheet with illustrative costs. It has not been bench-tested by this site. The timing figures below are from the commonly published NEC infrared format, which most small remotes use; remotes that use another protocol will decode differently. The button codes in the sketch are placeholders: the first step is to read your own remote’s codes. The IRremote library has changed between major versions, so check which one you installed.

## How it works

Many cheap remotes use the NEC format. A frame starts with a 9 ms burst and a 4.5 ms gap, then sends 32 bits on a 38 kHz carrier. A zero is a 562.5 µs burst followed by a 562.5 µs gap (1.125 ms in all), and a one is a 562.5 µs burst followed by a 1,687.5 µs gap (2.25 ms in all). That puts the frame at about 50 ms for all zeros and 86 ms for all ones, and a held button repeats about every 110 ms.

The receiver module does the demodulating and gives the Arduino a clean on/off signal, which the library decodes into an address and a command. The sketch uses only the command byte. Because a held button sends repeats, the car drives while repeats keep arriving and stops if none arrive for 250 ms.

## Bill of materials

| Part | Qty | Unit | Total |
| --- | --- | --- | --- |
| Arduino Uno R3 (or compatible) | 1 | ₹550 | ₹550 |
| IR receiver module (38 kHz, VS1838B style) | 1 | ₹30 | ₹30 |
| IR remote (a spare TV or kit remote) | 1 | ₹100 | ₹100 |
| L298N motor driver board | 1 | ₹180 | ₹180 |
| 2WD chassis kit with two gear motors and wheels | 1 | ₹450 | ₹450 |
| Battery holder with two 18650 cells | 1 | ₹210 | ₹210 |
| Jumper wires | 1 | ₹50 | ₹50 |
| Parts total | ₹1,570 |  |  |

Scroll the table sideways to see every column.

Prices checked Nov 2026. Shipping and tools are not included.

Prices are illustrative figures for Indian sellers in November 2026, before shipping, and have not been checked against current listings.

## The numbers

| Item | Time |
| --- | --- |
| Leading burst + gap | 13.5 ms |
| One zero bit | 1.125 ms |
| One one bit | 2.25 ms |
| Frame, all zeros (32 bits) | about 50 ms |
| Frame, all ones (32 bits) | about 86 ms |
| Repeat period while held | about 110 ms |

*Computed from the usual NEC description. Your remote may differ; the library reports what it actually receives.*

The 250 ms stop timeout is a little more than two repeat periods, so one lost repeat does not stop the car but two in a row do.

## Power and wiring

| Part | Connects to | Note |
| --- | --- | --- |
| IR receiver OUT, VCC, GND | D11, 5V, GND | Pin order differs between modules; check yours |
| L298N ENA / IN1 / IN2 | D5 / D7 / D8 | Left motor |
| L298N ENB / IN3 / IN4 | D6 / D9 / D4 | Right motor |
| Battery | L298N 12V input and Uno VIN | Check your pack voltage against the board limits |

*Keep the receiver away from the motors and its wires short; motor noise can add false pulses.*

## The sketch

```
// IR remote robot car: Uno + IR receiver + L298N
// Design worksheet: written for IRremote 4.x; check your version.
// Step 1: upload with LEARN = true, press each button, note the command.

#include <IRremote.hpp>

const bool LEARN = true;
const int RECV = 11;
const unsigned long TIMEOUT_MS = 250;
const int SPEED = 160;

// Placeholder codes: replace with the ones your remote prints.
const uint8_t CMD_FWD = 0x18, CMD_BACK = 0x52, CMD_LEFT = 0x08, CMD_RIGHT = 0x5A, CMD_STOP = 0x1C;

const int L_EN = 5, L_IN1 = 7, L_IN2 = 8;
const int R_EN = 6, R_IN3 = 9, R_IN4 = 4;
void drive(int left, int right) {   // -255..255 per side
  digitalWrite(L_IN1, left >= 0);  digitalWrite(L_IN2, left < 0);
  digitalWrite(R_IN3, right >= 0); digitalWrite(R_IN4, right < 0);
  analogWrite(L_EN, constrain(abs(left), 0, 255));
  analogWrite(R_EN, constrain(abs(right), 0, 255));
}
void motorsInit() {
  pinMode(L_EN, OUTPUT); pinMode(L_IN1, OUTPUT); pinMode(L_IN2, OUTPUT);
  pinMode(R_EN, OUTPUT); pinMode(R_IN3, OUTPUT); pinMode(R_IN4, OUTPUT);
}

unsigned long lastSignal = 0;
uint8_t current = 0;

void setup() {
  motorsInit();
  Serial.begin(115200);
  IrReceiver.begin(RECV, DISABLE_LED_FEEDBACK);
}

void loop() {
  if (IrReceiver.decode()) {
    uint8_t cmd = IrReceiver.decodedIRData.command;
    if (LEARN) { Serial.print("command 0x"); Serial.println(cmd, HEX); }
    if (cmd != 0) { current = cmd; lastSignal = millis(); }
    IrReceiver.resume();
  }
  if (millis() - lastSignal > TIMEOUT_MS) current = 0;

  if (LEARN) return;
  if      (current == CMD_FWD)   drive(SPEED, SPEED);
  else if (current == CMD_BACK)  drive(-SPEED, -SPEED);
  else if (current == CMD_LEFT)  drive(-SPEED, SPEED);
  else if (current == CMD_RIGHT) drive(SPEED, -SPEED);
  else                           drive(0, 0);
}
```

Set LEARN to false once the codes are filled in. A command of 0 is ignored because some remotes send a zero for a held key in certain formats; if your remote uses 0 for a real button, change that line. The sketch has been proofread but not compiled on this site.

## Test plan

1. **Learn codes:** with LEARN true, press each button and write the printed commands down.
2. **Range:** check how far and at what angle the car still hears the remote.
3. **Wheels up:** test each direction with the wheels off the floor first.
4. **Silence stop:** hold forward, cover the receiver and confirm the car stops within about a quarter second.
5. **Interference:** test in bright sunlight and near a fluorescent light.
6. **Held button:** check smooth motion while a key is held.

## What usually goes wrong

| Symptom | Likely cause | Fix |
| --- | --- | --- |
| Nothing decodes | Wrong receiver pin or order | Check OUT, VCC and GND on your module |
| Random commands | Motor noise or a weak supply | Shorten wires, add a capacitor near the receiver |
| Car keeps going | Timeout missing | Check the lastSignal logic |
| Works only at close range | Weak remote battery or poor angle | Replace the battery, aim at the receiver |
| Compile error on begin() | Different library version | Match the code to your IRremote version |

## Upgrades

- **Speed buttons:** use two remote keys to raise and lower speed.
- **Obstacle stop:** add an ultrasonic sensor and refuse forward motion near a wall.
- **Learn mode on the fly:** store codes in EEPROM.
- **Lights:** add headlights on a spare key.

## Cost and parts notes

The ₹1,570 total is an illustration and does not include shipping. Use the [cost calculator](https://roboticsengineering.in/robotics-project-cost-calculator/) to compare sellers.

## Common questions

**Why use a receiver module and not a bare photodiode?**

The module filters for the 38 kHz carrier and outputs clean pulses, which a bare diode does not.

**Do all remotes use NEC?**

No. Many do, but some use other formats. The library decodes several; check what yours prints.

**Why stop after 250 ms of silence?**

A held key repeats every 110 ms or so, so a gap this long means the key was released or the signal was lost.

**Which IRremote version?**

The code follows the 4.x style. Older 2.x examples look different, so match the example that came with your version.

Last reviewed: November 2026. This is a design worksheet with illustrative costs. It has not been bench-tested by this site; library names, pins and limits must be checked against your board and the current library versions, and measurements from your build are welcome.
