DEV Community

Cover image for What is micropython?
Axorax
Axorax

Posted on

What is micropython?

You may have heard the word "micropython". When I first came across this word, I was pretty confused. Is it a library for Python? What is it used for? And many more. In this post, I will try my best to explain what micropython is in simple terms. If I make any mistakes feel free to correct me in the comments.

What exactly is it?

Micropython is a simple implementation of Python 3. It's not a library for Python or anything. It has some of the standard libraries of Python.

Micropython is run on microcontrollers and it is optimized for it.

This is what they say about micropython on their website:

MicroPython is a lean and efficient implementation of the Python 3 programming language that includes a small subset of the Python standard library and is optimised to run on microcontrollers and in constrained environments.

The MicroPython pyboard is a compact electronic circuit board that runs MicroPython on the bare metal, giving you a low-level Python operating system that can be used to control all kinds of electronic projects.

MicroPython is packed full of advanced features such as an interactive prompt, arbitrary precision integers, closures, list comprehension, generators, exception handling and more. Yet it is compact enough to fit and run within just 256k of code space and 16k of RAM.

MicroPython aims to be as compatible with normal Python as possible to allow you to transfer code with ease from the desktop to a microcontroller or embedded system.

Summary:

MicroPython is a compact version of Python 3 for microcontrollers. It supports advanced features and a subset of the standard library. The MicroPython pyboard runs it directly on hardware for projects. It's compatible with standard Python for easy code transfer. It fits within 256k of code space and 16k of RAM.

How does the syntax look like?

import machine
import utime

# Configure the pin connected to the LED
led = machine.Pin(2, machine.Pin.OUT)

# Blink the LED in an infinite loop
while True:
    led.value(1)    # Turn the LED on
    utime.sleep(1)  # Wait for 1 second
    led.value(0)    # Turn the LED off
    utime.sleep(1)  # Wait for 1 second
Enter fullscreen mode Exit fullscreen mode

More information and download

Their website: https://micropython.org/
Download: https://micropython.org/download/

Hope you found it useful!

Top comments (1)

Collapse
 
axorax profile image
Axorax

Thanks for reading! Hope you enjoyed it!