What Is MicroPython?
Let’s learn how robots make decisions, repeat actions, and organize their thoughts—just like us!
🧠 What are control blocks?
Control blocks are like the brain of your robot. They help it:
- Decide what to do (
if) - Repeat things (
for,while) - Organize tasks (
def) - React to surprises (interrupts and callbacks)
🟡 1. if — The Decision Maker
“If something happens… then do this!”
Example Mission:
Turn on a light when someone presses a button.
MicroPython Code:
import machine
pin2 = machine.Pin(2, machine.Pin.OUT) # LED
pin4 = machine.Pin(4, machine.Pin.IN) # Button
if pin4.value() == 1:
pin2.value(1)
print("Button pressed: LED ON")
else:
pin2.value(0)
print("Button not pressed: LED OFF")
🎯 Your robot is learning how to make choices!
🔁 2. for — The Repeater
“Do this again and again, for each number or item.”
Example Mission:
Turn on 5 lights one by one.
MicroPython Code:
for i in range(0, 5):
print("Turning on LED", i)
# Imagine each LED lighting up in order!
🎯 Your robot is learning how to loop through actions!
🔄 3. while — The Watcher
“Keep doing this while something is true.”
Example Mission:
Keep the light on while the button is held down.
MicroPython Code:
while True:
if pin4.value() == 1:
pin2.value(1)
else:
pin2.value(0)
🎯 Your robot is learning how to stay alert and respond!
🧰 4. def — The Organizer
“Save this task with a name so you can use it anytime.”
Example Mission:
Create a shortcut to turn on the light.
MicroPython Code:
def turn_on_led():
pin2.value(1)
print("LED turned on!")
🎯 Your robot is learning how to organize its skills!
🚀 Why this matters
These blocks are the foundation of every robot project.
They help your robot think, act, and solve problems—just like you do.
1. What Is MicroPython?
a { text-decoration: none; color: #464feb; } tr th, tr td { border: 1px solid #e6e6e6; } tr th { background-color: #f5f5f5; }
1. What Is MicroPython?
Meet the Language Behind Your Blocks
When you build a program in Clu-Blocks Pro, you work with colorful blocks.
But behind those blocks, something interesting happens:
🧩 BLOCKS → 💻 MICROPYTHON → 🤖 D1 R32
Clu-Blocks Pro turns your blocks into code that the D1 R32 can run.
Don't worry. You don't need to memorize that code.
Let's discover what it means.
🟢 CORE
What Everyone Needs to Know
Complete this section first. It's all you need to continue.
🐍 What Is MicroPython?
MicroPython is a programming language designed to run on small computers called microcontrollers.
Our D1 R32 uses a microcontroller.
MicroPython gives us a way to tell it what we want our program to do.
Think of it like this:
💡 YOUR IDEA
↓
🧩 CLU-BLOCKS PRO
↓
💻 MICROPYTHON
↓
🤖 D1 R32
💻 Python and MicroPython
You may have heard of Python.
Python is a popular programming language.
MicroPython brings much of the Python programming experience to much smaller devices called microcontrollers.
For now, you only need to remember:
🐍 PYTHON
Programming language
and:
🔧 MICROPYTHON
Python designed to work on microcontrollers
That's enough!
🤖 What Is a Microcontroller?
A microcontroller is a small programmable computer that can be used inside electronic projects.
Later in Robotics, our D1 R32 will interact with things such as:
🔘 Buttons
💡 Lights
🌡️ Sensors
🔊 Buzzers
📺 Displays
⚙️ Servos and motors
But we don't need to learn those yet.
That's what Robotics is for.
For now:
🤖 MICROCONTROLLER
A small computer we can program
🧩 Where Does Clu-Blocks Pro Fit?
This is the important part.
With Clu-Blocks Pro, you don't have to start by typing every MicroPython instruction yourself.
You can build your program visually:
🧩 BLOCK
↓
Clu-Blocks Pro creates the corresponding code.
↓
💻 MICROPYTHON
↓
The program can run on the:
🤖 D1 R32
So the blocks and MicroPython are two ways of looking at your program.
👀 Your First Look at MicroPython
Look at this:
Python
print("Hello")
Don't memorize it.
Just notice that it looks different from blocks.
This instruction displays:
Plain Text
Hello
That's all we need to understand right now.
Later, we will discover what:
Python
print()
and:
Python
"Hello"
mean.
⭐ Remember This
You only need three ideas from this lesson:
1
🐍 MicroPython
is a programming language for microcontrollers.
2
🧩 Clu-Blocks Pro
lets us build programs visually.
3
💻 The blocks become MicroPython
that our D1 R32 can run.
That's it.
✅ CORE COMPLETE
You know enough to continue to the next lesson.
🔵 EXPLORE MORE
Curious? Let's Look a Little Deeper
This section is optional. You don't need it to continue.
🐍 Why Is It Called MicroPython?
Microcontrollers are much smaller and more resource-constrained than normal computers.
MicroPython is designed to bring Python programming to these smaller computing environments.
This lets programmers use familiar Python-style code while working with electronic devices.
🧠 Code Is Another Way to Describe Your Blocks
Imagine that a visual block represents:
Plain Text
Display "Hello"
The generated MicroPython might contain an instruction that expresses the same programming idea.
So don't think:
❌ BLOCKS vs. CODE
Instead think:
✅ BLOCKS ↔ CODE
They are different representations of your program.
🔎 Why Do We Want to See the Code?
You might be wondering:
If Clu-Blocks Pro creates the code, why should I learn anything about MicroPython?
Great question.
Because later you will begin recognizing what your blocks produce.
You'll see things like:
Python
score = 10
Python
if score > 5:
Python
while True:
and instead of thinking:
😵 “What is all this?”
you'll begin thinking:
💡 “I recognize that!”
That's the goal of Coding Basics.
Not memorizing code.
RECOGNIZING AND UNDERSTANDING IT
🧩 The Two Views of Your Program
Think about Clu-Blocks Pro as giving us two useful views:
🧩 BLOCK VIEW
Easy to build and explore visually.
↓
💻 CODE VIEW
Lets us see the MicroPython behind our program.
The important thing isn't choosing one or the other.
It's learning how they connect.
🧩 BLOCK → 💻 CODE → 🧠 MEANING
✅ EXPLORE COMPLETE
If that made sense, great.
If you skipped this section, that's also okay.
You're still ready to continue.
🟣 DEEPER
Want to Know What's Really Happening?
Optional. This section is for curious learners, older students, teachers, and anyone who wants more detail.
What exactly is MicroPython?
More precisely, MicroPython is an implementation of the Python 3 programming language designed for microcontrollers and constrained computing environments.
MicroPython keeps much of Python's syntax while providing capabilities appropriate to supported embedded hardware.
This is why MicroPython code can look very similar to Python code while running in a very different environment.
Python and MicroPython Are Not Exactly the Same
For beginners, saying:
“MicroPython is Python for microcontrollers”
is a useful mental model.
Technically, however, Python environments and MicroPython are not identical.
There can be differences in:
- Available libraries
- Hardware-specific features
- Memory and resource constraints
- Some language and implementation details
You don't need to understand those differences before starting Robotics.
The important technical idea is simply:
SIMILAR LANGUAGE → DIFFERENT ENVIRONMENT
Hardware-Specific Code
Later you may see generated code such as:
Python
import machine
The name:
Plain Text
machine
is associated with MicroPython functionality for interacting with hardware.
Don't memorize this yet.
When you encounter it later, just remember:
💡 Some MicroPython code exists specifically to communicate with the microcontroller's hardware.
We will discover the practical meaning of this naturally during Robotics.
🧠 Technical Summary
At the deepest level, our learning path looks like:
🧩 VISUAL PROGRAM
↓
💻 GENERATED MICROPYTHON
↓
⚙️ PROGRAM EXECUTION
↓
🤖 MICROCONTROLLER
↓
Later:
🌎 PHYSICAL WORLD
And this is where programming becomes robotics.
✅ TECHNICAL COMPLETE
You've gone beyond what you need for this lesson.
Nice work!
🎯 QUICK CHECK
Before moving on, can you answer these three questions?
What is MicroPython?
A programming language designed to run on microcontrollers.
What does Clu-Blocks Pro help us do?
Build programs visually using blocks.
Do you need to memorize the generated MicroPython?
No!
Our first goal is to learn how to recognize and understand it.
