We saw loads of excellent Raspberry Pi-powered builds at Open Sauce in San Francisco last week. This Raspberry Pi Pico-powered chess-playing robot by Noah Davis was one of our favourites, so we asked him to send us some info about how he built it.
Noah’s inferior chess game was getting him down, so he decided to build a robot to play for him. Of course, this has already been done before, so he decided to add a twist to the game to make it feel more like you’re playing a human opponent. ChatGPT was brought in to procedurally generate speech and, more importantly, insults. If you’re not berated for making dumb moves, did you even really play chess?
How does it work?
Magnets are fixed on the bottom of every chess piece, and an array of Hall effect sensors are placed on the underside of the board. Raspberry Pi Pico connects to each Hall sensor in rows and columns, similar to the way you would wire a mechanical keyboard.
The Pico connects to Noah’s computer’s serial port to run the Stockfish open source chess engine. This software decides which move the robot should make next.
Chess board sensor data is requested from the Pico by the computer, which then compares that data to a previous snapshot. This is where things got tricky. The chess board sensors can detect if a square is in use or not, but it has no idea what piece is on it. Noah got round this with some clever code which tracks each piece from its known starting position on the board. That took a long time to pull together, and Noah squeezed in the coding in the early hours of the morning between school work.
Servo motors powering the robotic chess player’s arm positions are sent over serial to Raspberry Pi Pico and translated into a signal to tell the servos how to move.
The LED light bar on the side of the chess board signals whose turn it is. If it’s blue, take your go, but if it’s red, you’ll have to wait for your robot opponent to scrape an idea from Stockfish for their next move. Cheating really. This robot lives a lie.
More content coming
Once high school work calms down, Noah plans to start making more engineering and programming video content for his YouTube channel. He made that quick show reel at the top of this post especially for Open Sauce, but a full project video is in the works. Make sure you subscribe to get a notification when it goes live.