Project Overview

Turn an Arduino Uno R4 into a fully functional USB game controller that your computer recognizes as a keyboard. Using a joystick and tactile buttons, this DIY controller sends directional and action inputs (like arrow keys and WASD) via USB — perfect for retro games or custom control interfaces.

This build blends basic electronics and microcontroller programming to make something playable, tactile, and fun — ideal for maker workshops, gaming hacks, or interactive installs.

What You’ll Build

A compact Arduino game controller with:

Parts List

You’ll need:

Circuit & Wiring

Joystick:

Buttons:

This wiring lets the Uno read analog joystick positions and digital button presses.

Building It Step-by-Step

  1. Connect the joystick to the analog inputs and power pins on the Arduino.

  2. Wire the push buttons to digital pins (2–5) and ground, enabling internal pull-ups in software.

  3. Mount everything on perfboard neatly — solder for strength and durability.

  4. Connect the Arduino to your PC via USB for power and data.

How It Works

Once plugged into a computer, the Uno R4 uses the USB HID (Human Interface Device) protocol to appear as a keyboard. This allows it to send keypresses directly — without drivers — making the controller compatible with almost any PC game that supports keyboard input.

Joystick logic:

Button logic:

Arduino Code Example

#include <Keyboard.h>

// Pins
const int joyX = A0;
const int joyY = A1;
const int buttonPins[4] = {2, 3, 4, 5};

// Thresholds
const int LOW_TH = 350;
const int HIGH_TH = 670;

// Key maps
const char buttonKeys[4] = {'w','a','s','d'};

void setup() {  for (int i = 0; i < 4; i++) {    pinMode(buttonPins[i], INPUT_PULLUP); // enable internal pull-up  }  delay(3000);      // allow USB to enumerate  Keyboard.begin(); // start HID
}

void loop() {  // Read joystick  int x = analogRead(joyX);  int y = analogRead(joyY);
  // Directional keys  if (x < LOW_TH)      Keyboard.press(KEY_LEFT_ARROW);  else                  Keyboard.release(KEY_LEFT_ARROW);
  if (x > HIGH_TH)     Keyboard.press(KEY_RIGHT_ARROW);  else                  Keyboard.release(KEY_RIGHT_ARROW);
  if (y < LOW_TH)      Keyboard.press(KEY_UP_ARROW);  else                  Keyboard.release(KEY_UP_ARROW);
  if (y > HIGH_TH)     Keyboard.press(KEY_DOWN_ARROW);  else                  Keyboard.release(KEY_DOWN_ARROW);
  // Buttons  for (int i = 0; i < 4; i++) {    if (digitalRead(buttonPins[i]) == LOW)      Keyboard.press(buttonKeys[i]);    else      Keyboard.release(buttonKeys[i]);  }
  delay(10);
}

This sketch continuously checks control states and sends corresponding keypresses to the PC.

Tips & Troubleshooting

Why This Is Cool

Check out the 500+ Arduino Projects collection on CircuitDigest for a massive library of Arduino tutorials with code, schematics, and step-by-step guides across robotics, IoT, automation and more.