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.

About the author · Editorial & verification standards

  • Parts₹1,510
  • Bench time3–4 h
  • LevelBeginner
  • ReviewedNov 2026

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.

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

PartQtyUnitTotal
Arduino Uno R3 (or compatible)1₹550₹550
Analog joystick module1₹90₹90
L298N motor driver board1₹180₹180
2WD chassis kit with two gear motors and wheels1₹450₹450
Battery holder with two 18650 cells1₹210₹210
Jumper wires1₹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 wheelRight wheelResult
0, 111Straight ahead at full speed
1, 01−1Spin right on the spot
0.5, 0.510Pivot around the right wheel
0.8, 0.810Same pivot, after scaling from 1.6 and 0
0.3, 0.60.90.3Forward, curving right
−0.3, 0.60.30.9Forward, curving left
0, −0.5−0.5−0.5Reverse at half speed
0, 000Stopped
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

PartArduino UnoNote
Joystick VRxA0Sideways
Joystick VRyA1Forward; flip Y_SIGN if it reads backwards
Joystick +5V and GND5V and GND
L298N ENA / IN1 / IN2D5 / D7 / D8Left motor, ENA is PWM
L298N ENB / IN3 / IN4D6 / D9 / D4Right motor, ENB is PWM
BatteryL298N 12V input and Uno VINCheck 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

SymptomLikely causeFix
Creeps when the stick is releasedDead zone too small or centre misreadRaise DEAD, power up with the stick centred
Forward turns the robot backwardsY axis reads the other waySet Y_SIGN to −1
Left and right swappedMotor wires or x sign reversedSwap the motor wires or flip the sign of x
One wheel does not move at low pushBelow the motor’s minimum PWMRaise PWM_MIN
Jerky responseJoystick noiseAverage a few readings
Resets under loadWeak supplyFresh 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 to compare sellers.

Common questions

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

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

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

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.

More builds

Next builds to try

Free: the final-year project pack

A shortlist with BOMs, a report outline that matches the usual chapter scheme, a costing sheet and 40 viva questions. Built for the February–April submission season.

The Build Note

One short email when something is worth your bench time.

A new build sheet, a part price that moved, or a mistake worth avoiding. No daily drip, no recycled news.

One short email when a build or a price is worth your time. Unsubscribe in one click.