D1 R32

🎮 First Words

Microproject Image

Module Goal: meet your robot's brain and learn its voice the Serial Monitor. No extra hardware yet: the board and your PC are the platform.

Goal: 

write your very first program and make your robot greet the world on the PC screen. 

Concepts: 

Serial Output · Print Statement · Program Execution 

Create four println blocks with these messages, upload, and watch the Serial Monitor.

print("=================================")   # A decorative line to open the show
print("     HELLO! I AM A Clu-Bot")            # The robot's very first words
print("     My name is Toto")               # Write YOUR robot's name here
print("     Nice to meet you, human.")       # A friendly closing line

Serial Monitor: 

=================================

HELLO! I AM A Clu-Bot 

My name is Toto

Nice to meet you, human.

💡 Note: the computer read your program top to bottom, one line at a time exactly the order you placed the blocks. This order rule never changes, in any program you will ever write. Choose your robot's name carefully: it keeps it for the whole course.

🎮 The Robot Breathes

Microproject Image

Goal: 

build a counter that never stops your first variable and your first infinite loop.

Concepts: 

Variable · Counter · Infinite Loop · Delay You need: a variable `count` set to `0`, a `repeat while (true)` block, the self-calculation block (`+=`), a two-item `println`, and a 1-second delay.

import time  # Library that lets us pause the program
count = 0   # Our counter starts at zero
while True:  # Repeat these steps forever
    count += 1  # Add one to the counter (0 becomes 1, 1 becomes 2...)
    print("Breath number:", count) # Show the number on the PC
    time.sleep(1)  # Rest one second between breaths

Serial Monitor (it never stops scrolling): 

Breath number: 1 

Breath number: 2 

Breath number: 3 ... 

💡 Note: a variable is a box with a name count is a box holding a number that changes every second. And here is your first big rule of robots: programs run forever unless you design a way out. How do you stop this one? The reset button on the board. Try it.

🎮 The Living Stopwatch

Microproject Image

Goal: 

discover that your board carries its own clock, and report how long it has been alive. 

Concepts: 

Internal Clock · Milliseconds · Integer Division · Loop 

You need: repeat while (true), the System running time (ms) block, a math block with // 1000, a two-item println, and a 1-second delay.

import time  # Library for pauses and time

while True:  # Repeat forever
    ms = time.ticks_ms()  # Milliseconds since the board woke up
    seconds = ms // 1000  # Divide by 1000: whole seconds only (// drops decimals)
    print("I have been alive for", seconds, "seconds")  # Report to the PC
    time.sleep(1) # Update once per second

Serial Monitor: 

I have been alive for 3 seconds 

I have been alive for 4 seconds 

I have been alive for 5 seconds 

💡 Note: ticks_ms() counts milliseconds since wake-up. The // division throws away decimals: 4387 ms becomes just 4 seconds. Detective challenge: unplug and replug the board. The clock returns to 0! The board's clock is a stopwatch that restarts every time it wakes up.

🎮 The Robot Listens

Microproject Image

Goal: 

have your first two-way conversation type your name and receive a personalized greeting. 

Concepts: 

Serial Input · Waiting for Data · String Variable 

You need: two println blocks, a variable name connected to a Receive String Input block, and one more println using the variable.

print("=== TALKING TO THE ROBOT ===")            # Welcome banner
name = input("What is your name? ")              # The program FREEZES here until you type and press Enter
print("Hello,", name, "!")                       # Greet you using YOUR name
print("I will remember you forever...")          # A playful robot line

Serial Monitor (your typed text appears after the prompt):  === TALKING TO THE ROBOT === 

What is your name? Sofia 

Hello, Sofia ! 

I will remember you forever... 

💡 Note: input() is a trap that freezes your program nothing happens until you type and press Enter. Whatever you typed is stored in the variable name, and the robot can use it as many times as it wants. Until now your robot only had a mouth; now it has ears too.

🎮 MISSION: Mini-Assistant

Microproject Image

Goal: 

build a command menu your robot answers HELLO, TIME and ECHO, and politely refuses anything else. 

Concepts: 

Command Menu · Conditionals (if / elif / else) · String Comparison · Serial Input & Output 

This is your biggest program yet build it slowly, one command at a time, testing after each one.

import time # Library for time

print("=== MINI ASSISTANT ===") # Title of the program
print("Commands: HELLO, TIME, ECHO") # Show the menu so the user knows what to type

while True: # Serve commands forever
    cmd = input("You: ") # Wait for you to type a command
    if cmd == "HELLO": # Did you type Hello exactly?
        print("Robot: Hello, human friend!") # Greeting response
    elif cmd == "TIME":  # Or did you type TIME?
        ms = time.ticks_ms()                         # Milliseconds since wake-up
        seconds = ms // 1000                         # Convert to whole seconds
        print("Robot: I have been awake for", seconds, "seconds")   # Report uptime
    elif cmd == "ECHO": # Or did you type ECHO?
        msg = input("Robot: What should I repeat? ") # Ask for the message to repeat
        print("Robot:", msg) # Say it back like an echo
    else:  # Anything else at all
        print("Robot: I do not know that command") # Politely refuse it

Serial Monitor:

 === MINI ASSISTANT === 

Commands: HELLO, TIME, ECHO 

You: HELLO

Robot: Hello, human friend! 

You: TIME

Robot: I have been awake for 42 seconds 

You: ECHO

Robot: What should I repeat? Clu-Block is awesome 

Robot: Clu-Block is awesome 

You: PIZZA 

Robot: I do not know that command 

💡 Note: three secrets live here. ① The comparison is exact: hola (lowercase) is NOT the same as HOLA computers are extremely literal. ② The else is your safety net: unknown commands never crash the program, they just get refused.