💡 Level 1 – Fundamentals
Level 0: Foundations
🎓 Mini‑Tutorial 1: Variables
Think of variables as little boxes where your robot stores information.
- Definition: A variable is a name that holds a value (like a number or a word).
- Real world: It’s like a backpack pocket where you keep something safe until you need it.
Example Mission: Store your name
# Create a variable called 'name' and store a word
name = "Alex" # Put "Alex" inside the box called name
# Show the value of the variable
print("My name is:", name) # Print the contents of the box
🎯 Your robot just remembered something!
🎓 Mini‑Tutorial 2: Logic
Logic helps your robot think with True or False answers.
- Definition: Logic checks if something is equal, bigger, smaller, or different.
- Real world: It’s like asking yes/no questions.
Example Mission: Compare numbers
x = 5
y = 3
print(x == y) # False, because 5 is not equal to 3
print(x > y) # True, because 5 is greater than 3
print(x < y) # False, because 5 is not less than 3
🎯 Your robot can answer questions with True or False!
🎓 Mini‑Tutorial 3: Control Blocks
Control blocks are the robot’s thinking powers.
- Definition: They tell the robot when to act, how long to repeat, and when to stop.
- Real world: Like following instructions in a game: “If you see a coin, pick it up.”
Main control blocks
- if / else: Make decisions.
- for loop: Repeat a set number of times.
- while loop: Keep going while something is true.
- def (function): Save a group of instructions with a name.
Example Mission: Blink a light 5 times
import machine
pin2 = machine.Pin(2, machine.Pin.OUT) # LED on Pin 2
for i in range(5): # Repeat 5 times
pin2.value(1) # Turn LED ON
print("LED ON") # Serial message
pin2.value(0) # Turn LED OFF
print("LED OFF") # Serial message
🎯 Control blocks make your robot repeat actions without writing the same code over and over.
🎓 Mini‑Tutorial 4: Meet the D1 R32 Board
The D1 R32 is the brain of your robot.
- Digital pins (D1, D2…): Work like switches. ON = 1, OFF = 0.
- Analog pins (A1, A2…): Measure levels like brightness or sound.
- ADC (Analog‑to‑Digital Converter): Turns analog signals into numbers.
- PWM (Pulse Width Modulation): Controls speed or brightness by turning ON/OFF very fast.
- SCL and SDA: Special pins for talking to displays and sensors (used later).
- Bonus: Built‑in Bluetooth and Wi‑Fi for communication.
Example Mission: Read a sensor value
import machine
adc32 = machine.ADC(machine.Pin(32)) # Analog sensor on Pin A0 (32)
adc32.atten(machine.ADC.ATTN_11DB) # Set range
adc32.width(machine.ADC.WIDTH_12BIT) # Set resolution
value = adc32.read() # Read sensor value
print("Sensor reading:", value) # Show it on the computer
🎯 Your robot can sense the world by reading numbers from its pins.
🚀 Why Level 0 Matters
- Variables = memory.
- Logic = thinking.
- Control = planning.
- D1 R32 basics = connecting to the world.
Together, they give students the foundation to understand every project in Level 1 and beyond.