DEV Community

Cover image for First Steps Creating a Robot with MicroPython and Pyboard
Halldor Stefansson
Halldor Stefansson

Posted on • Edited on • Originally published at halldorstefans.com

First Steps Creating a Robot with MicroPython and Pyboard

Photo by Alexandre Debiève on Unsplash

What are MicroPython and PyBoard

MicroPython is a software implementation of the Python 3 programming language, written in C, that is optimised to run on a microcontroller.

It was Damien George who created MicroPython. He developed it along with running a Kickstarter campaign to fund it and the pyboard.

The pyboard is a compact and powerful electronics development board that runs MicroPython.

The aim of MicroPython is not to replace C, but to provide a way to program microcontrollers using Python.

Why Build a Robot

After finishing the 'Intro to Self Driving Cars' program, I wanted to build something, like a small car.

And I wanted it to be able to drive around without crashing by sensing its environment.

I started by buying a small robot kit, which included a chassis, two DC motors, wheels, and a caster ball for balance.
But of course, I would need something that would control the motors, and be the "driver".

Why Use MicroPython

I already owned a pybord that I had bought about four or five years ago. But, since then, it had been a dust collector.

I had written some small programs to turn the LEDs on and off, but that was it. I never tried to connect a component to it, and get that to work.

I thus thought this would be an excellent opportunity to finally use the pyboard. But I didn't know how it worked.

Therefore I didn't know how to get it to control my car.

First steps

I needed to get familiar with the board and came across these tutorials for the pyboard.
The first ten tutorials are good to get started, needing only the pyboard, a USB cable and a computer. It's a helpful introduction to the board and its possibilities.

In the second part of the tutorials, you'll need some components. But I didn't have them all so; I did only the ones where I did have the elements.
It was a good feeling to get something physical to work.

But the motors in the robot kit I bought are DC motors, and none of the tutorials demonstrated how to control them.

So I wondered how to use the pyboard to control a DC motor.

Next steps

Reading the description for the robot kit, I saw that run motors will need ~5V and 1.5 A.
But according to this response on the MicroPython forum, the max current per pin is 25mA.
We see there's a considerable gap between what the motors need and what the pyboard can provide.

After a bit of research, I realised that I needed something to control the motors.

So my next steps are to understand better what I need and how to use it.


If you liked what you read, please consider signing up to my newsletter

Top comments (0)