The gripper mechanism is used to pick up and place chess pieces. It consists of a servo for vertical motion and an electromagnet to hold the pieces.

Animation of the gripper picking up and putting down a piece.


The electromagnet is attached to the bottom on the rod and can be controlled via Python through A GPIO pin connected to the gate of a transistor. The transistor is connected in circuit with a 12V power supply and a 1” diameter electromaget with 19 lbs. holding force. A detailed spec sheet for the electromagnet can be found here. The electromagnet is from APW Company, who sells tons of different kinds and sizes of electromagnets and other custom coils.

Circuit diagram of the electromagnet connected to the Raspberry Pi.

The code controlling the electromagnet can be found in the file in the project. The relevant parts of the file are below.

import RPi.GPIO as GPIO
electromagnet_pin = 40
GPIO.setup(electromagnet_pin, GPIO.OUT)

def electromagnet(self, on):
	output = GPIO.HIGH if on else GPIO.LOW
	GPIO.output(electromagnet_pin, output)
# Dynamically turn on/off electromagnet
electromagnet(True) # On
# ... move piece to another square ...
electromagnet(False) # Off


The vertical motion, to pick up and put down pieces, is accomplished with a gear rack kit made out of Actobotics from ServoCity. The Hitec HS-785HB Servo is controlled by the Raspberry Pi via adjusting the PWM signal of a GPIO pin. This rotation moves the aluminum beam that the electromagnet is attached to. Relevant code for controlling the gripper servo in Python is found in

Circuit diagram of the servo connected to the Raspberry Pi.
Animation of the gear rack kit servo in motion.
Animation of the gear rack kit moving a piece up/down


The chess pieces are a set of plastic 3 3/4” Colored Chess Pieces in neon green and orange. The colors provided enough visual distinction for computer vision algorithms. The top of each piece was drilled and a small metal dowel, from a local hardware store, was interted. This allowed the electromagnet to lift the pieces.

The chess pieces, with a small metal dowel in the top of each one.
There is a small metal dowel in the top of each piece.

Click here to learn about how the Raspberry Turk sees the chessboard next.