Cover image for PicoTico

PicoTico

PicoTico is a Raspberry Pi Pico powered robot that plays TicTacToe.

3 March 2024
4 minute read

By Kevin McAleer
Share this article on


Table of Contents


  Difficulty:
beginner


PicoTico

PicoTico is a Raspberry Pi Pico powered robot that plays TicTacToe.


 3 March 2024   |     4 minute read   |   By Kevin McAleer   |   Share this article on

Video

For every project I create, I often make a corresponding YouTube video. Sometimes, there might be more than one video for a single project. You can find these videos in this section.

Explore more through this this dedicated video.

A few weeks ago, I decided to create my own robot that could play tic tac toe using Raspberry Pi Pico. The journey was challenging and exciting, filled with lessons and discoveries.

Introduction

The Raspberry Pi Pico - Tic Tac Toe Playing Robot - Pico Tico is an interesting project that can play Tic Tac Toe using a Raspberry Pi Pico, an ST7735 screen, and a few servos. It’s a great project for anyone interested in robotics or coding, as it provides an opportunity to create something fun and interactive.


Starting with The Basics

The Pico Tico robot originated from a project called Tico, which was based on an Arduino Nano. However, for my rendition, I decided to use Raspberry Pi Pico and MicroPython. The end result is a robot that possesses various skills such as playing Tic Tac Toe, drawing game boards, and handling human players.

The project itself leans heavily on Inverse Kinematics, a subject that was new to me. Inverse Kinematics essentially allows you to focus on where you want the pen to be rather than focusing on the servos.


Translating Arduino into MicroPython

Translating Arduino code into MicroPython wasn’t as hard as you might think. While there were a few gotchas, for the most part, finding the equivalent MicroPython libraries for the Arduino ones was a straightforward task.

However, one issue that I encountered was when I left out some brackets around parts of my codes in Arduino, leading to errors when translated to MicroPython. It turns out the servo positioning requires consistent adjustments in MicroPython, so the brackets were essential.


What it can do

Capabilities


Hardware and Software

Hardware and software


Wiring

How it works

Inverse Kinematics

How it works

How it works


How Inverse Kinematics Works

Inverse Kinematics is a method used to calculate the joint parameters of a robot to achieve a desired position. In the case of Pico Tico, it is used to calculate the angles of the servos to position the pen at a specific point on the screen.

How it works

How it works

How it works

How it works

How it works

How it works

How it works

How it works

How it works

How it works

How it works

How it works

How it works


3D Printable STL files

This project was originally created by Playtronics. The 3D printable STL files can be found at https://www.thingiverse.com/thing:4946788


MicroPython Code

The MicroPython code for the Pico Tico robot can be found at https://www.github.com/kevinmcaleer/Pico-Tico. The robot is programmed in MicroPython.


Things Learned

Working on this project allowed me to learn several things. For instance, I realized that global variables in Python can be read fine, but if you desire to make changes to them within a function, you have to use the ‘global’ command.

Another challenge I faced was finding a correct power supply. I burned three of my MG90 servos by mistakenly using a 9V battery instead of a proper power supply.

As for the physical elements of the project, finding a correctly sized pen and making sure it fits within a 3D printed holder was a challenge. Using a combination of both small dry erase markers and standard Sharpie markers, I was able to fit the pen into the holder perfectly.


Future Directions

What excites me more about this project is its scope for improvement. Firstly, I am looking to implement a minmax algorithm – a decision-making tool used in game theory for minimizing the possible loss for a worst-case scenario. This would make the robot more efficient at Tic Tac Toe.

Secondly, I want to explore more drawing capabilities. For example, creating a rendition of the robot that can sketch out post-it notes or a robot that could draw Bob Ross-style paintings but with an erasable canvas. The possibilities are diverse and fascinating.


Conclusion

Creating a Tic Tac Toe Robot with Raspberry Pi Pico was an exciting and educational project. Not only did it provide a deep dive into coding and robotics, but also it offered room for creativity and innovation. If you are also looking forward to building something similar, the starter code and project files can be found at github.com/kevinmclear/pico-tico.

Take up this project, avoid the pitfalls I fell into, and enjoy the journey to making your own tic tac toe-playing robot!