Source: https://mokxi.com/parts/gamepad
Updated: 2026-11-10

Part

# Game console buttons

A D-pad plus A and B, six switches to ground. Click them, or use the arrow keys, Z and X.

See every part

- 7 pins
- 1 setting
- In 5 projects
- In 3 lessons

Drawn live by the editor's own code, at the size you see it.

At a glance

## The Game console buttons in brief

What it is, and every setting the properties panel gives it.

The gamepad is a six-button console-style pad, a four-way D-pad plus A and B, with every button a contact to a shared ground and no chip, shift register or serial protocol on the board. Its pins are UP, DOWN, LEFT, RIGHT, A, B and GND, and no supply. On an Uno each button goes to its own digital pin with INPUT_PULLUP and reads LOW when pressed; an ESP32 wires it the same way on any six GPIOs. Mokxi models a pressed button as a low-resistance contact to GND and a released one as an open pin. The rocker property, on by default, drops the older of two opposed directions the moment the second arrives, as a one-piece rocker does, so held arrow keys can never read up and down at once; diagonals stay allowed. Click the buttons, or use the arrow keys with Z and X. The mokxi_gamepad.h driver adds an 8 millisecond settle and gives held(), pressed(), dx() and dy(). The classic mistake is forgetting the pull-ups, which leaves released buttons floating. Contact bounce, which a real carbon-pill pad has for a fraction of a millisecond, is not modeled.

Family

Inputs

Pins

7

rocker

true

on by default: models the plastic rocker that makes opposite directions
mechanically impossible.

Pins

## 7 pins

Named as the editor names them, so a wire lands where you expect it.

Pin

What it does

UP

Each shorts to GND when pressed.

DOWN

Each shorts to GND when pressed.

LEFT

Each shorts to GND when pressed.

RIGHT

Each shorts to GND when pressed.

A

Each shorts to GND when pressed.

B

Each shorts to GND when pressed.

GND

The common return.

How to use it

## How to use a six-button gamepad with an Arduino

Each button is a contact to the shared GND, so wire GND to ground and the six buttons to six digital pins with their pull-ups on. In D-pad pong, UP is pin 7, DOWN 8, LEFT 5, RIGHT 4, A 3 and B 2. Click the pad or use the arrow keys with Z and X.

The mokxi_gamepad.h driver sets the pull-ups in begin() and, called once a frame, update() lets a change through after 8 ms. held() says a button is down, pressed() that it went down since the last update, and dx() gives -1, 0 or 1 from the D-pad. The pad’s rocker property stops up and down, or left and right, reading pressed at once.

Part pin

Board pin

UP

Pin 7

DOWN

Pin 8

LEFT

Pin 5

RIGHT

Pin 4

A

Pin 3

B

Pin 2

GND

GND

mokxi_gamepad.h works the same on an ESP32: the pad has no supply pin, only contacts to ground.

Click to open it in the editor

This is the simulator itself, running here. Click anything to open it in the editor.

Open this project in the editor Read the full tutorial

Reading the pad, from D-pad pong

How it is modeled

## What is true about the Game console buttons, here

In its help article’s own words: what the simulation gets right, and where it stops.

### Modeled

A pressed button is a real low-resistance contact to GND; released, the pin is
high impedance and whatever pull-up the board provides decides the level. rocker
models the molded plastic rocker a real D-pad has: on by default, it drops the
older of two opposed directions the instant the second one arrives, which is what a
one-piece rocker does mechanically and what stops a keyboard's held arrow keys from
producing a state no hardware could ever make.

### Not modeled

No contact bounce. A molded pad's carbon-pill contacts make far more quietly than
a tactile switch does, so this part does not chatter; the
pushbutton is the part to reach for when bounce is the
lesson. "Far more quietly" is not "silently", though: a real pad does chatter for a
fraction of a millisecond and this one never does at all.

rocker is a rule rather than a mechanism: it drops the older of two opposed
directions the instant the second arrives. A real rocker cannot be pressed on two
opposite sides at once at all, and on the way between two directions it passes through
a moment with neither made; neither of those is modeled. There is no diagonal
restriction either, so up and left together are allowed, as they are on a real pad.

From Gamepad (six-button pad), in full.

Projects

## See the Game console buttons in a project

5 built-in projects use it. Each opens in the editor, already wired.

Lessons

## Where it turns up in a lesson

3 lessons place it in their own circuits.

### Learn articles

3 lessons

- DIY Fight Stick on an Arduino Pro Micro
- Leverless Controller Build: Buttons, Pins and Code
- SOCD Cleaning Explained, With Code

Boards

## The boards it is shown on

Each of these 3 boards has a built-in project with the Game console buttons in it.

- Arduino Uno R3
- ESP32-C3-DevKitM-1
- SparkFun Pro Micro

More parts

## The rest of the bench

Every one of these is drawn and simulated the same way.

Full-size breadboard

A real 0.1 inch grid with the rails and the center channel, 63 columns wide.

Jumper wires

Drag from any pin or hole to any other. Corners snap, and you can drag them.

Power

A supply rail at the voltage you choose.

Ground

The other end of every circuit.

LED

Lights when current flows. Five colors, and the brightness is what your eye would see.

Filament lamp

A tungsten bulb in a holder: an inrush when it is switched on cold, tens of milliseconds to warm up, and dim on half its voltage.

Resistor

Any value you like, with the color bands drawn to match.

ESP32-C3-DevKitM-1

A RISC-V board that runs your firmware at 160 MHz on the real memory map.

Pushbutton

A 12 mm tactile switch. Hold it while the simulation runs.

Raspberry Pi Pico

The RP2040 board on our own Cortex-M0+ core. Pick a program and press Run.

Raspberry Pi Pico W

Raspberry Pi Pico W (RP2040). The same board and the same pinout as a Pico, with the CYW43439 on it. The WiFi is simulated (no radio; real internet through the Cloud panel’s switch), and the on-board LED, which hangs off that chip rather than off GP25, is driven through the same path. Everything else is the Pico.

Raspberry Pi 4 Model B

Raspberry Pi 4 Model B: the 40-pin header, driven by main.py with RPi.GPIO or gpiozero.

See every part

## Wire up the Game console buttons

Open the editor and push it into the breadboard. It is free, and it runs on your own machine.

Start building free Open the editor
