# Joystick-driven robot with arcade drive mixing on Arduino: design worksheet and code

> A ₹1,510 design worksheet for driving a two-wheel robot with one analog joystick: the arcade-drive mixing maths, a dead zone, a worked table and a sketch.

Canonical: https://roboticsengineering.in/projects/joystick-arcade-drive-robot-arduino/ | Published: 2026-11-04 | Updated: 2026-11-04

**A ₹1,510 robot you drive with one thumb. An analog joystick gives two numbers, forward and sideways, and the sketch mixes them into a speed for each wheel. The page shows the mixing maths with a worked table, a dead zone so the robot does not creep, and a sketch.**

**Scope:** beginner. This is a design worksheet with illustrative costs. It has not been bench-tested by this site. The mixing table below was computed by script. The joystick is wired to the board with a cable, so the robot is tethered; a wireless version is a later upgrade. For phone control instead, see the [Bluetooth robot car](https://roboticsengineering.in/projects/bluetooth-robot-car-hc05-arduino/).

## How it works

A two-wheel robot is driven by a left and a right speed. A joystick gives x (sideways) and y (forward), each from −1 to +1. This is called arcade drive: left = y + x and right = y − x. Pushing straight forward drives both wheels equally. Pushing sideways alone makes the wheels run opposite ways, which spins the robot on the spot. A diagonal push blends the two.

The sum can exceed 1, for example a push of 0.8 forward and 0.8 right gives a left value of 1.6. A wheel cannot go that fast, so the sketch divides both values by the larger one. That keeps the ratio between the wheels, and so the turn, while using full speed.

## Bill of materials

| Part | Qty | Unit | Total |
| --- | --- | --- | --- |
| Arduino Uno R3 (or compatible) | 1 | ₹550 | ₹550 |
| Analog joystick module | 1 | ₹90 | ₹90 |
| 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 | ₹30 | ₹30 |
| Parts total | ₹1,510 |  |  |

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.

## Worked mixing values

| Joystick x (right), y (forward) | Left wheel | Right wheel | Result |
| --- | --- | --- | --- |
| 0, 1 | 1 | 1 | Straight ahead at full speed |
| 1, 0 | 1 | −1 | Spin right on the spot |
| 0.5, 0.5 | 1 | 0 | Pivot around the right wheel |
| 0.8, 0.8 | 1 | 0 | Same pivot, after scaling from 1.6 and 0 |
| 0.3, 0.6 | 0.9 | 0.3 | Forward, curving right |
| −0.3, 0.6 | 0.3 | 0.9 | Forward, curving left |
| 0, −0.5 | −0.5 | −0.5 | Reverse at half speed |
| 0, 0 | 0 | 0 | Stopped |

*Left = y + x and right = y − x, scaled so neither exceeds 1. Positive x turns right, so the left wheel runs faster.*

## The dead zone

A joystick rarely rests at exactly the middle of its range, and the analog-to-digital converter reads 0 to 1023, with the middle near 512. Without a dead zone the robot creeps. The sketch reads the resting values at power-up as the centre and ignores anything within 8 percent of full travel, about 41 counts on each side. A reading of 530 counts as zero; 560 counts as 0.094 and the robot starts to move.

## Power and wiring

| Part | Arduino Uno | Note |
| --- | --- | --- |
| Joystick VRx | A0 | Sideways |
| Joystick VRy | A1 | Forward; flip Y_SIGN if it reads backwards |
| Joystick +5V and GND | 5V and GND |  |
| L298N ENA / IN1 / IN2 | D5 / D7 / D8 | Left motor, ENA is PWM |
| L298N ENB / IN3 / IN4 | D6 / D9 / D4 | Right motor, ENB is PWM |
| Battery | L298N 12V input and Uno VIN | Check your pack voltage against the board’s limits |

*Leave the joystick centred while the board powers up so the centre is read correctly.*

## The sketch

```
// Joystick arcade drive: Uno + L298N + analog joystick
// Design worksheet: leave the stick centred at power-up.

const int X_PIN = A0;
const int Y_PIN = A1;
const int Y_SIGN = 1;               // set to -1 if pushing forward reads as backwards
const float DEAD = 0.08;            // dead zone as a fraction of full travel
const int PWM_MIN = 90;             // below this the motors may not turn

const int L_EN = 5, L_IN1 = 7, L_IN2 = 8;
const int R_EN = 6, R_IN3 = 9, R_IN4 = 4;

int xCentre = 512, yCentre = 512;

float norm(int raw, int centre) {
  float n = (raw - centre) / 512.0;
  if (fabs(n) < DEAD) return 0;
  return constrain(n, -1.0, 1.0);
}

void drive(float left, float right) {   // -1..1
  digitalWrite(L_IN1, left >= 0);  digitalWrite(L_IN2, left < 0);
  digitalWrite(R_IN3, right >= 0); digitalWrite(R_IN4, right < 0);
  analogWrite(L_EN, left == 0 ? 0 : PWM_MIN + (255 - PWM_MIN) * fabs(left));
  analogWrite(R_EN, right == 0 ? 0 : PWM_MIN + (255 - PWM_MIN) * fabs(right));
}

void setup() {
  pinMode(L_EN, OUTPUT); pinMode(L_IN1, OUTPUT); pinMode(L_IN2, OUTPUT);
  pinMode(R_EN, OUTPUT); pinMode(R_IN3, OUTPUT); pinMode(R_IN4, OUTPUT);
  delay(500);
  xCentre = analogRead(X_PIN);
  yCentre = analogRead(Y_PIN);
}

void loop() {
  float x = norm(analogRead(X_PIN), xCentre);
  float y = Y_SIGN * norm(analogRead(Y_PIN), yCentre);

  float left = y + x;
  float right = y - x;
  float m = max(fabs(left), fabs(right));
  if (m > 1.0) { left /= m; right /= m; }

  drive(left, right);
  delay(10);
}
```

The lowest PWM value that actually turns the motors depends on your motors and battery, so the sketch maps any non-zero command into the range from PWM_MIN to full. Find your own PWM_MIN by raising it from zero until the wheels just turn on your floor.

## Test plan

1. **Wheels off the ground:** prop the robot up and push the stick forward, back, left and right. Swap a motor’s two wires if one wheel runs the wrong way.
2. **Dead zone:** let go of the stick and confirm the wheels stop. If they creep, raise DEAD or recheck the centre reading.
3. **Straight line:** push forward and see whether it drifts. Small motor differences are normal; you steer them out.
4. **Spin:** push fully sideways and confirm it turns on the spot.
5. **Curves:** try the diagonal values from the table and see whether the turn matches.
6. **Battery:** repeat with a tired pack and note how PWM_MIN changes.

## What usually goes wrong

| Symptom | Likely cause | Fix |
| --- | --- | --- |
| Creeps when the stick is released | Dead zone too small or centre misread | Raise DEAD, power up with the stick centred |
| Forward turns the robot backwards | Y axis reads the other way | Set Y_SIGN to −1 |
| Left and right swapped | Motor wires or x sign reversed | Swap the motor wires or flip the sign of x |
| One wheel does not move at low push | Below the motor’s minimum PWM | Raise PWM_MIN |
| Jerky response | Joystick noise | Average a few readings |
| Resets under load | Weak supply | Fresh batteries, check the connections |

## Upgrades

- **Wireless:** send the joystick values with a pair of radio modules or over Bluetooth.
- **Soft response:** square the stick value for finer control near the centre.
- **Speed limit:** add a button that switches between slow and fast.
- **Failsafe:** stop the motors if the wire or the link goes quiet.

## Cost and parts notes

The ₹1,510 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

**What is arcade drive?**

It is a way to drive a two-wheel robot with one stick: left wheel = forward + turn, right wheel = forward − turn.

**Why scale the values?**

The sum can exceed what a wheel can do. Dividing both by the larger keeps the turn shape while using full speed.

**Why do I need a dead zone?**

A stick never rests at exactly the centre, so without one the robot creeps.

**Can I use this with a phone?**

Yes. Send the same two numbers over Bluetooth or Wi-Fi and use the same mixing.

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.
