Getting Started with MicroPython
Currently, the MicroPython downloads page shows 186 boards currently supported with a binary download available.
This means it shouldn't be hard to find a compatible board to work with.
For this "Getting Started" class, I will focus on the Raspberry Pi Pico board.
Just like many of the libraries available to download for peripheral support,
some "tweeking" may be required to get things working for you.
Raspberry Pi Pico
RP2040 processor, 133MHz, 264KB RAM, 2Mbyte FLASH
Raspberry Pi Pico2
RP2350 processor, 150MHz, 520KB RAM, 4Mbyte FLASH
Each of the above boards is available with WiFi and/or pre-installed headers
Class Prerequisites
• Windows / Linux / Mac PC (Laptop) • Thonny IDE, version 4.1.7 (or later) https://thonny.org/ • MicroPython Capable Development Board Any of the of the boards identified on this page: https://micropython.org/download/ • USB Cable for Development Board
Terminology
REPL
A Python REPL (Read-Eval-Print Loop) is an interactive way to execute Python code. It reads user input, evaluates it, prints the result, and loops back to read more input.
Outline
- General Python – Comments
- General Python - Looping – Using “for”, “range()”, and “print()”
- General Python – Looping – Using “continue” and “break”
- General Python – Variables, “global” keyword
- General Python - Lists
- General Python – Functions
- MicroPython – Defining Pins, Pin functions
- MicroPython – LEDs, Buttons
General Python – Comments
Comments begin with: # Comment block – Begin and End with three quotes, single or double: ’’’ or ””” See comments.py
#comments.py # Comments begin with a '#' character. Either on a blank line x = 3 # or following a line of code # If you have a large multi-line comment or wish to comment out some code # you can use three quotes to begin and end the comment block ' ' ' # Using single quotes for this comment block i = 7 fruit = 'apple' brain = 'dead' salary_adjustment = -0.07 # This year we have a negative adjustment ' ' ' actual_code = "here" """ # Using double quotes for this comment block i35 = 'stopped' i635 = "parking lot" i75 = 'nail biter' """ more_code = "more more more" print(x, actual_code, more_code) # using a comma between items adds a space
General Python - Looping – Using “for”, “range()”, and “print()”
See range.py