Arduino Automatic Chessboard started with the moving chess pieces from Harry Potter and one question: could a real chessboard understand what is happening on it, think about the next move, and push a piece on its own? A magnet under the board can drag a piece across the squares, so the job comes down to moving that magnet accurately.
Circuit Digest sponsored the Builder in Residence: Hardware Edition Hackathon in collaboration with TinkerSpace, Kochi. Supporting the next generation of hardware innovators, makers, and builders!
In this project, I am building an Arduino automatic chessboard prototype where a magnet under the board moves the pieces. An Arduino Uno with a CNC Shield V3 drives two NEMA 17 motors through DRV8825 drivers, an MG90S servo lifts a magnet to the underside of the board, and a desktop app on a laptop sends the moves over USB. Stockfish runs separately as a small web service. Right now the automatic chessboard is an XY motion prototype. The carriage jogs in the right directions from a1, but it has not moved a real piece yet, so this guide covers the motion, calibration and software in full, and the pickup as far as it has been tested. You can also check out similar Arduino projects and robotics projects done previously here at Circuit Digest.
Table of Contents
- What Is Arduino Automatic Chessboard?
- How Does it Work?
- Components Required
- Wiring Diagram
- └ CNC Shield V3 Pin Connections
- Testing the Motion Electronics on the Bench
- Building the Magnet Lift
- Uploading the Firmware and Running the Desktop GUI
- OpenMove Serial Commands
- Calibrating the Board Mapping
- Running the Stockfish API
- Code Explanation
- Live Video Demonstration
- Output
- Troubleshooting
- OpenMove GitHub Repository
What is Arduino Automatic Chessboard?
Arduino Automatic Chessboard has a mechanism under the board that moves a piece, a Stockfish engine that picks a reply, and a planned 8 × 8 grid of Hall-effect sensors to find the pieces. The Arduino handles pins, steps and the magnet, while the laptop owns the chess rules, the game state and the engine, and a move from Stockfish should never reach the motors until the host has checked it against the board. If you build your own, start with the motion. Circuit Digest has also covered an autonomous chessboard that uses an ESP32 and Stockfish. If interested, do check it out.
How Does the Arduino Automatic Chessboard Work?
The work is split between the laptop and the Arduino. The desktop app keeps the game state with python-chess and sends one move at a time over USB serial at 115200 baud. The Uno turns that move into square coordinates, and the two DRV8825 drivers on the CNC Shield step the NEMA 17 motors, which pull the carriage on GT2 belts in an H-bot layout. On the carriage, an MG90S servo raises a magnet to the underside of the board to catch a piece and lowers it again to let go. Below is the block diagram of the Arduino automatic chessboard.

The dashed boxes are not connected yet. The Stockfish API works on its own, and the Hall-effect grid is still an idea. The servo-and-carriage idea is close to the pen lift in the Circuit Digest Arduino CNC plotter, where a mini servo raises and lowers the pen.

Below is the flowchart of the firmware running on the Uno.
The firmware starts with the drivers switched off and waits for you to place the carriage at the centre of a1 and send HOME. A chess move only runs if the carriage is homed, the board has been confirmed with RESETBOARD, and the move is legal and free of captures, castling, en passant and promotion. If a move fails halfway, the firmware marks the board as untrusted, because the pieces may no longer match its stored position.
Components Required for the Arduino Automatic Chessboard
Below is the list of components required to build this project.

| S.No | Component | Description | Quantity |
| 1. | Arduino Uno (CP2102 USB) | Low-level motion controller | 1 |
| 2. | CNC Shield V3 | Driver sockets, STEP/DIR/ENABLE breakout | 1 |
| 3. | DRV8825 Stepper Driver | 1/8 microstepping, VREF about 0.65V | 2 |
| 4. | NEMA 17 Stepper Motor | 1.8° steps, drives the belts | 2 |
| 5. | GT2 Belt with 20-Tooth Pulleys | H-bot transmission | As required |
| 6. | Stainless-Steel Rod, 4mm × 300mm | Linear support | 2 |
| 7. | MG90S Servo | Raises and lowers the magnet | 1 |
| 8. | Permanent Magnet TODO: size and grade | Catches a piece through the board | 1 |
| 9. | 3D-Printed Rack and Pinion | Turns servo rotation into vertical travel | 1 set |
| 10. | 12V 3A Adapter | Motor power | 1 |
| 11. | Regulated 5V Supply TODO: model | Servo power | 1 |
| 12. | Chessboard and Pieces TODO: board thickness and piece base | 44mm between square centres | 1 set |
| 13. | Laptop with Python 3 | Desktop GUI, terminal UI, pythonchess | 1 |
The Uno in my photos is a diy board with a CP2102 USB chip, which is why it shows up as /dev/ttyUSB0 on Linux. The firmware's 40 steps per millimetre comes from the 1.8° motors, the DRV8825s set to 1/8 microstepping, and a GT2 belt on 20-tooth pulleys, so keep those three the same or recalculate MOTOR_STEPS_PER_MM. For a first look at this motor and driver pair, refer to the NEMA 17 with Arduino and DRV8825 tutorial on Circuit Digest.
Wiring Diagram of the Arduino Automatic Chessboard
Below is the wiring diagram for the Arduino Automatic Chessboard.

The CNC Shield sits on top of the Uno, and the two DRV8825 drivers plug into its X and Y sockets, as per the table below. The firmware names the motors A and B, as both of them work together on every move in an H-bot. The servo signal goes to the shield's Z+ limit-switch header, which is D11 on the Uno. Power the servo from a separate regulated 5V supply with its ground tied to the shield ground, and never connect it to the 12V motor supply. The 12V 3A adapter feeds the motor side, and a motor should never be plugged in or pulled out while that supply is on. That is all about the wiring. If you are new to servos, do check out our servo motor with Arduino guide.
CNC Shield V3 Pin Connections
| Device | CNC Shield V3 Connection | Arduino Pin |
| Motor A driver STEP / DIR | X socket | D2 / D5 |
| Motor B driver STEP / DIR | Y socket | D3 / D6 |
| Shared driver ENABLE | Shield enable, active LOW | D8 |
| MG90S servo signal | Z+ limit-switch header | D11 |
Testing the Motion Electronics on the Bench
Test the electronics on the desk before building any mechanics. Below are the Uno and the CNC Shield with its two DRV8825 drivers.

Set the driver current first. Both of my drivers measured about 0.65V on VREF, but the current limit also depends on the sense resistors on each driver board, so read their markings and set VREF from them. I have not done that yet, so my actual limit is still unknown.
Then upload code/hardware_smoke_test/hardware_smoke_test.ino. It sends 100 pulses to both motors together at about 50 steps per second, pauses, reverses, and swings the servo between 30 and 120 degrees, over and over. Both of my motors moved and reversed together, and the servo followed. Below is the servo from that test.

This test proves the whole chain is alive, but it does not check each motor on its own or any movement under load, so test each motor alone as well.
Building the Magnet Lift
A magnet sitting at one height cannot choose whether to hold a piece or let it go, so it needs a way to move up and down. A servo rotates, and the magnet has to travel vertically, so a 3D-printed rack and pinion sits between them. Below are the linear servo mechanism and its 3D model.

The repository's CAD folder has only a README so far, so model and print your own bracket, pinion and rack. The magnet has to come close enough to carry a piece through the board, and drop far enough away to leave it behind. In the firmware, a 2100 µs pulse puts the magnet against the underside of the board, which I checked by eye, and 1000 µs takes it clear. The servo gets 500 ms to settle before the carriage moves, since nothing measures its position. I have not done a successful piece transfer yet, so tune the magnet and the two pulse widths on your own board. In addition to this build, here is a collection of 3D printing projects for reference.
Uploading the Firmware and Running the Desktop GUI
The steps below set up the firmware and the desktop controller on a Linux laptop.
Step 1⇒ Upload the Firmware
The sketch is code/openmove_chess/openmove_chess.ino. Compile and upload it to the Uno with the Arduino IDE or with arduino-cli, as shown below. Close the GUI first, as it holds the serial port.
arduino-cli compile --fqbn arduino:avr:uno code/openmove_chess
arduino-cli upload --port /dev/ttyUSB0 --fqbn arduino:avr:uno code/openmove_chessStep 2⇒ Start the Desktop GUI
Install the GUI requirements, PySide6 and python-chess, in a virtual environment and start it with the serial port.
python -m venv .venv
source .venv/bin/activate
pip install -r code/requirements-gui.txt
python code/openmove_gui.py --port /dev/ttyUSB0The terminal UI needs only Python's standard library, and python code/openmove_tui.py --port /dev/ttyUSB0 starts it, with --home and --reset to send HOME and RESETBOARD at startup. Below is the GUI before connecting. Its move controls stay disabled until the controller reports protocol 7, the A1 mapping, a home and a confirmed board.

Step 3⇒ Set Home and Reset Board
An upload clears both confirmations. Move the carriage by hand to the centre of A1 and press Set Home. Then arrange the pieces in the starting position and press Reset Board. These buttons only record what you did. They do not move anything back for you.
Step 4⇒ Start with Small Jogs
Use the 1 mm and 10 mm jogs to check both directions before trying GOTO, a move or a PGN.
OpenMove Serial Commands
| Command | What It Does |
| HOME | Sets the current carriage position as a1 and enables the drivers |
| RESETBOARD | Confirms the standard starting position |
| STATUS, SELFTEST | Reports the mapping, home, trust and stop state |
| JOGX+1, JOGX-10, JOGY+1, JOGY-10 (and the other signs) | Move 1 mm or 10 mm along one axis |
| GOTO e4 | Moves the carriage to the centre of a square |
| e2e4, Nf3 | Plays a legal, non-capturing chess move |
| RETURN e4e2 | Moves a piece back without the rules check, for PGN restore |
| MAGNET90, MAGNET0 | Raises the magnet to the board or takes it clear |
| DISABLE | Switches the drivers off and clears home |
| ! or Ctrl-X | Emergency stop |
Commands are not case-sensitive.
Calibrating the Board Mapping
The Arduino does not know where the carriage is when it starts, and there is no limit switch, so the mapping between squares and motor steps has to be checked on the real board. Below is the coordinate mapping I ended up with, next to the two wrong guesses that came before it.

Measure the distance between neighbouring square centres first. Mine is 44 mm, which puts h8 at (308, 308) with a1 at (0, 0). Then home at a1 and check that a small positive X jog moves towards b1 and a positive Y jog towards a2. After that, test GOTO on squares far from a1. My first origin label, h1, sent GOTO g1 to g8, and the second, h8, sent GOTO e2 to d7, which meant the mapping was rotated by 180 degrees and the real origin was a1. Firmware 2.5 fixed this by reversing only the logical X axis with REVERSE_LOGICAL_X. Finally, check the travel, as seven 44 mm gaps add up to 308 mm while my rods are 300 mm long.
Running the Stockfish API
The engine lives in the stockfish folder of the repository as a small FastAPI app in a Docker container. It takes a full FEN position and a search time between 50 and 5000 ms, checks an API key, and replies with a best move in UCI notation, such as e2e4. To run it locally, put a long random key in the environment file and start the container.
cd stockfish
cp .env.example .env # set OPENMOVE_API_KEY, e.g. openssl rand -hex 32
docker compose up --build
curl http://localhost:8080/healthThe container is limited to one CPU and 512 MiB of memory and runs on a read-only filesystem. Mine runs on an Azure VM, bound to 127.0.0.1:8080, so I reach it through an SSH tunnel, and public DNS and TLS are still pending. The recorded warm responses on the VM are below.
| Search Time | Response Time on the VM |
| 50 ms | About 59 ms |
| 250 ms | About 255 ms |
| 500 ms | About 506 ms |
These timings are for the service on the VM, not a round trip from the board. Five API tests pass, with the success test using a mock engine. A more basic electronic chessboard is the DIY computer chessboard using a Raspberry Pi on Circuit Digest.
Arduino Automatic Chessboard Code Explanation
The firmware is written in the Arduino IDE for the Uno. Version 2.7 in the repository speaks serial protocol 7 at 115200 baud, and the desktop GUI is written in Python with PySide6 and python-chess. Below are the main parts.
Pins and Calibration
const uint8_t A_STEP_PIN = 2;
const uint8_t B_STEP_PIN = 3;
const uint8_t A_DIR_PIN = 5;
const uint8_t B_DIR_PIN = 6;
const uint8_t ENABLE_PIN = 8; // Active LOW.
const uint8_t ACTUATOR_PIN = 11; // CNC Shield Z+ header; PWM signal only.
const float MOTOR_STEPS_PER_MM = 40.0f;
const float SQUARE_SIZE_MM = 44.0f; // User-measured adjacent square centres.
const bool REVERSE_LOGICAL_X = true;
const int ACTUATOR_RETRACT_US = 1000; // Magnet raised / piece released.
const int ACTUATOR_EXTEND_US = 2100; // Confirmed surface contact.These constants hold the pin map and the numbers measured on the real board, so change SQUARE_SIZE_MM and MOTOR_STEPS_PER_MM for your own board and drive. The comment on 1000 µs says "raised", while my build notes describe the magnet going up to grab a piece, so check the direction on your own build.
Turning X and Y into Two Motors
float logicalX = REVERSE_LOGICAL_X ? -x : x;
float mappedX = SWAP_X_Y ? y : logicalX;
float mappedY = SWAP_X_Y ? logicalX : y;
long targetA = lroundf((mappedX + mappedY) * MOTOR_STEPS_PER_MM);
long targetB = lroundf((mappedY - mappedX) * MOTOR_STEPS_PER_MM);
if (!moveMotors(targetA, targetB)) return false;The moveTo() function converts a position in millimetres into step targets. In this H-bot mapping, motor A follows X plus Y and motor B follows Y minus X, so a straight move along one axis turns both motors.
Carrying a Piece
bool pickupSquare(uint8_t file, uint8_t rank) {
releaseMagnet();
if (!moveTo(squareX(file), squareY(rank))) return false;
engageMagnet();
return !motionAborted;
}To move a piece, the carriage goes to the source square with the magnet clear, raises the magnet, travels to the destination and lowers it. Most pieces travel in a straight line between square centres, since a legal move already has a clear path. The magnet cannot jump, so for a knight, planKnightMove() tries three square-by-square routes, parks up to two blocking pieces on empty squares, moves the knight, and then puts the blockers back. This planner has not been tested on the board yet.
Checking a PGN Before Replay
for move in moves:
if board.is_capture(move):
raise ValueError("PGN captures are not physically supported yet")
if board.is_castling(move):
raise ValueError("PGN castling is not physically supported yet")
if move.promotion:
raise ValueError("PGN promotions are not physically supported yet")
board.push(move)parse_replayable_pgn() in the GUI walks through every move of the PGN before anything is sent, so an unsupported move cannot turn up halfway through a replay.
Restoring the Board with RETURN
move = self.playback_moves[self.playback_index - 1]
reverse_move = chess.square_name(move.to_square) + chess.square_name(move.from_square)
self._send(f"RETURN {reverse_move}", success=self._pgn_return_completed,
timeout=120.0, playback=True)After the last move, the GUI waits 10 seconds and plays the moves backwards with RETURN, so e2e4 comes back as RETURN e4e2. RETURN skips the rules check, as a pawn moving backwards would fail it. With Loop after restore ticked, it checks the controller status and plays the PGN again, or stops if home or board trust was lost.
Live Video Demonstration
Below is the video demonstration of OpenMove.
TODO: video of the carriage jogging from A1, a GOTO test and the GUI connected to the controller
Output: Testing the Arduino Automatic Chessboard Prototype
Below is what the controller prints when it starts, taken from the firmware's setup().
OpenMove chess motion controller 2.7
mapping:home=a1,+x=a-to-h,+y=1-to-8,white=ranks-1-2
mode:white-and-black automation; captures disabled
ready: place carriage at a1 centre, then send HOMEThe smoke test ran on the hardware, and both motors and the servo moved. After firmware 2.5, the small positive X and Y jogs matched a1 to b1 and a1 to a2 on the board. Firmware 2.6 compiled to 19,146 bytes of flash and 858 bytes of RAM, was uploaded, and a read-only status query confirmed protocol 7 and the a1 mapping. The records disagree on whether 2.7 was uploaded, so the installed version still needs checking. No full-square accuracy test, piece pickup or physical PGN replay has been done yet.
Troubleshooting the Arduino Automatic Chessboard
| Symptom | Likely Cause | Fix |
| GOTO g1 goes to g8 | The origin label does not match the real corner | Test GOTO from the real a1, then fix the mapping in firmware |
| One motor hums, or the Y driver runs warmer | Current limit or wiring not verified | Read the sense resistors, set VREF from them, and test each motor alone |
| Upload fails because the port is busy | The GUI still holds /dev/ttyUSB0 | Disconnect the GUI before arduino-cli upload |
| GUI shows Mapping mismatch and moves are disabled | Firmware reports a different protocol or origin | Upload firmware that reports protocol 7 and the A1 mapping |
| error:not-homed or error:confirm-standard-physicalboard | Home or board trust lost after an upload, a stop or a failed move | Put the carriage at A1, press Set Home, set up the pieces, press Reset Board |
| The carriage stops short of the h-file or the 8th rank | 300 mm rods for 308 mm of travel between a1 and h8 | Measure the real travel before fullboard moves |
Lessons From Our Build
Keep motor direction and board direction as separate settings. In an H-bot, both motors turn for every straight move, so flipping one motor does something different from flipping the board's X axis, and mixing the two makes a test hard to read.
Test the mapping with GOTO on far squares as well as one-square jogs. Both of my wrong origin labels showed up in GOTO tests across the board, and the second set of tests showed that the whole mapping was rotated by 180 degrees.
Do not trust VREF alone on clone drivers, as the same reading can mean a different current limit when the sense resistors differ. After one fast test, one of my motors hummed, and the Y driver ran warmer than the X driver, and I have not found the cause yet.
Conclusion
Arduino Automatic Chessboard has the electronics, the firmware, a desktop controller and a Stockfish service, and the carriage jogs in the right directions from a properly labelled a1, but the hard part is still the mechanism. The next milestone is a repeatable full-square move from a1, then homing, then a magnet that moves exactly one piece and leaves it behind. There is still room for improvement, such as automatic homing, measured driver current limits and the 8 × 8 Hall-effect grid for finding pieces. Further, one can start that sensing work with this Hall effect sensor with an Arduino tutorial on Circuit Digest.
OpenMove GitHub Repository
The OpenMove repository has the Uno firmware, the desktop GUI and terminal UI, the hardware smoke test, the Stockfish API with its Dockerfile and tests, and the build notes. Arduino Automatic Chessboard is built by Mishal at Tinkerspace for Builder in Residence, with a replay trust fix contributed by arxhr007. The repository has no licence file.
Frequently Asked Questions About Arduino Automatic Chessboard
⇥ 1. Can Arduino Automatic Chessboard play a full game of chess yet?
No. Captures, castling, en passant, promotion and automatic homing are not supported, and no piece has been moved on the board yet. The firmware and GUI only allow non-capturing moves.
⇥ 2. Why does the Arduino not run Stockfish itself?
The Uno already handles the pins, steps and magnet timing, so Stockfish runs on a server, and the host checks its move against the board before the Arduino moves anything.
⇥ 3. How does OpenMove know where the pieces are?
It does not sense them yet. You set up the starting position by hand and confirm it with RESETBOARD, and the firmware tracks the moves from there.
Related Arduino Uno Projects: CNC Machines and Stepper Motor Control
Explore more Arduino Uno projects focused on CNC machine development, stepper motor control, and precision motion automation. Learn how to build an Arduino-based CNC plotter, control a NEMA 17 stepper motor using the DRV8825 driver, and interface the advanced TMC2209 stepper motor driver with Arduino Uno for accurate direction and stepping control.
DIY Arduino-Based CNC Plotter Machine
This DIY Arduino CNC Machine can draw most of the basic shapes, text, and even cartoons. Its operation is similar to the way a human hand writes. It’s faster and more accurate compared to the way a human being can write or draw.
Control a NEMA 17 Stepper Motor with Arduino Uno
In this tutorial, we are going to control a NEMA 17 stepper motor using an Arduino Uno and a DRV8825 stepper module. We will also use a potentiometer to control the direction of the stepper motor to rotate it in clockwise and anti-clockwise directions.
Interfacing TMC2209 Stepper Motor Driver with Arduino UNO
In this comprehensive TMC2209 Arduino tutorial, we'll walk through a complete example of how to interface a Bigtree Tech TMC2209 stepper motor driver with Arduino UNO for precise directional rotation and step control.





Add a comment
No account needed. Your comment appears once a moderator has reviewed it.