This page (revision-43) was last changed on 2025-08-05 16:02 by Murray Altheim

This page was created on 2025-07-23 02:43 by Murray Altheim

Only authorized users are allowed to rename pages.

Only authorized users are allowed to delete pages.

Page revision history

Version Date Modified Size Author Changes ... Change note
43 2025-08-05 16:02 3 KB Murray Altheim to previous
42 2025-08-05 16:02 3 KB Murray Altheim to previous | to last
41 2025-08-05 16:01 3 KB Murray Altheim to previous | to last

Page References

Incoming links Outgoing links

Version management

Difference between version and

At line 1 changed 2 lines
This is the home page for a __MicroPython Tutorial__, a modest attempt at providing a beginner with the
basics of programming in MicroPython, in particular on a Raspberry Pi Pico.
This is a placeholder page for a MicroPython Tutorial.
At line 4 changed 5 lines
If you're having trouble finding this page, here's the URL of the server:
%%url
http://service.robots.org.nz/wiki/
%%
''(for use in a classroom)''
! Here's the URL of the server:
At line 10 changed one line
!! Exercises
!!! service.robots.org.nz/wiki/
At line 12 changed 6 lines
* [MicroPython Tutorial Exercise 1|MicroPythonTutorialExercise01]: main.py
* [MicroPython Tutorial Exercise 2|MicroPythonTutorialExercise02]: blocks
* [MicroPython Tutorial Exercise 3|MicroPythonTutorialExercise03]: functions
* [MicroPython Tutorial Exercise 4|MicroPythonTutorialExercise04]: classes
* [MicroPython Tutorial Exercise 5|MicroPythonTutorialExercise05]: using classes
* [MicroPython Tutorial Exercise 6|MicroPythonTutorialExercise06]: tbd
%%python
At line 19 changed one line
Additional exercises:
from machine import Pin
from motor import Motor
from motor_controller import MotorController
At line 21 changed 5 lines
* [The REPL|MicroPythonTutorialTheREPL]
* [Objects and Names|MicroPythonTutorialObjectsAndNames]
* [Scope|MicroPythonTutorialScope].
* [Exception Handling|MicroPythonTutorialExceptionHandling].
* [String Formatting|StringFormatting].
# ┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈
class Motor:
At line 27 changed one line
!! Documentation & References
def __init__(self, name):
self.motor_name = name
self.motor_speed = 0
print("motor {} ready.".format(self.motor_name))
At line 29 changed one line
The complete documentation for Python and MicroPython (as used on microcontrollers) is available here:
def set_speed(self, speed):
self.motor_speed = speed
print("speed: {}".format(speed))
At line 31 changed 7 lines
* [Python documentation|https://docs.python.org/3/]
** [Beginner's Guide|https://wiki.python.org/moin/BeginnersGuide]
* [MicroPython documentation|https://docs.micropython.org/en/latest/]
** [Language Reference|https://docs.micropython.org/en/latest/reference/index.html]
** [Libraries Reference|https://docs.micropython.org/en/latest/library/index.html]
** [Glossary of MicroPython terms|https://docs.micropython.org/en/latest/reference/glossary.html]
* [Awesome MicroPython|https://awesome-micropython.com/], a huge curated list of MicroPython libraries and resources
def get_speed(self):
return self.motor_speed
At line 39 changed one line
See also the [Python] and [MicroPython] pages on this wiki.
# ┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈
class MotorController:
At line 31 added 4 lines
def __init__(self):
self.port_forward_motor = Motor('pfwd')
self.stbd_forward_motor = Motor('sfwd')
print("motor controller ready.")
At line 42 removed one line
!! Online
At line 44 changed one line
! Tutorials
# main ┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈
At line 46 changed 6 lines
* __Python__
** [The Python Tutorial|https://docs.python.org/3/tutorial/index.html] (the official tutorial)
** [Learn Python Tutorial|https://www.learnpython.org/]
* __MicroPython__
** [MicroPython tutorial for the pyboard|https://docs.micropython.org/en/latest/pyboard/tutorial/index.html] (the official tutorial)
** [MicroPython: An Intro to Programming Hardware in Python|https://realpython.com/micropython/]
motor_ctrl = MotorController()
At line 53 changed 27 lines
! Simulators
These are online tools that let you try out Python and MicroPython from a Web browser. Python
and MicroPython are very similar so learning either one helps you with the other:
* __Python__
** [Online Python|https://www.online-python.com/]
** [Online Python with AI help|https://sim.lvgl.io/v8.3/micropython/ports/javascript/index.html]
** [OnlineGDB|https://www.onlinegdb.com/online_python_compiler]
** [Programmiz Python Online Compiler|https://www.programiz.com/python-programming/online-compiler/]
* __MicroPython__
** [MicroPython Live|https://micropython.org/live/] (official site)
** [LVGL/MicroPython simulator|https://sim.lvgl.io/v8.3/micropython/ports/javascript/index.html]
* Developer Tools
* [Mu IDE|https://codewith.mu/]
* [Thonny IDE|https://thonny.org/]
* [mpremote|https://docs.micropython.org/en/latest/reference/mpremote.html], a command line tool to "remotely interact with, manage the filesystem on, and automate a MicroPython" device over a serial connection
* [rshell|https://github.com/dhylands/rshell], a command line access to a pyboard (similar to mpremote)
----
__Next:__ [MicroPython Tutorial Exercise 1|MicroPythonTutorialExercise01]: main.py
%%