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

6 4

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

Image of AssemblyAI tool

Transforming Interviews into Publishable Stories with AssemblyAI

Insightview is a modern web application that streamlines the interview workflow for journalists. By leveraging AssemblyAI's LeMUR and Universal-2 technology, it transforms raw interview recordings into structured, actionable content, dramatically reducing the time from recording to publication.

Key Features:
🎥 Audio/video file upload with real-time preview
🗣️ Advanced transcription with speaker identification
⭐ Automatic highlight extraction of key moments
✍️ AI-powered article draft generation
📤 Export interview's subtitles in VTT format

Read full post

Top comments (0)

Sentry image

See why 4M developers consider Sentry, “not bad.”

Fixing code doesn’t have to be the worst part of your day. Learn how Sentry can help.

Learn more

👋 Kindness is contagious

Engage with a sea of insights in this enlightening article, highly esteemed within the encouraging DEV Community. Programmers of every skill level are invited to participate and enrich our shared knowledge.

A simple "thank you" can uplift someone's spirits. Express your appreciation in the comments section!

On DEV, sharing knowledge smooths our journey and strengthens our community bonds. Found this useful? A brief thank you to the author can mean a lot.

Okay