Lesson plan

MicroPython on the Pico lesson plan

Real Python on a Raspberry Pi Pico: blink and the REPL, buttons and if, loops and PWM, a knob on the ADC, lists and functions on an LED bar, an OLED on I2C, and a reaction game boss.

4 chapters, 7 lessons, about 3 hours, on the Raspberry Pi Pico. Every lesson runs in the browser, with nothing to install.

The unit

Objectives and materials

By the end, students can

  • Blink two LEDs, type Python live into the board, and make choices with if.
  • Fade with a for loop and PWM, and read a knob with the ADC.
  • Lists and functions on an LED bar, and text on an OLED over I2C.
  • A reaction timer with a random wait, a cheat catcher and a best score.

Materials for the whole unit

  • Full-size breadboard
  • LED x 6
  • OLED display, 128x64
  • Potentiometer
  • Pressure, humidity and temperature, BME280
  • Pushbutton
  • Raspberry Pi Pico
  • Resistor x 6

Every part is already on the simulator’s bench, so there is nothing to buy or hand out. The counts are the most any one lesson uses, if you build it on real breadboards too.

Chapter 1. About 50 min

First Python

Blink two LEDs, type Python live into the board, and make choices with if.

LessonTimeWhat students do
Blink, and talk to the boardYour first MicroPython program blinks two LEDs, then you type Python straight into the board with the REPL.25 min
  1. Run it
  2. print() talks back
  3. The REPL: Python you type live
  4. Drive a pin by hand
Buttons and ifRead a button with a pull-up, make a choice with if and else, and print only when something changes.25 min
  1. Run it and press
  2. if and else
  3. Print only on a change
  4. Turn it round

Materials

  • LED
  • Pushbutton
  • Raspberry Pi Pico
  • Resistor

Check for understanding

Each student finishes "Buttons and if" on their own, without opening the hints. The simulator checks 4 of its 4 steps as they go.

Then ask each one to explain, in a sentence or two, the last thing it asked of them: "Turn it round".

Chapter 2. About 50 min

Loops and sensors

Fade with a for loop and PWM, and read a knob with the ADC.

LessonTimeWhat students do
Loops and a PWM fadeA for loop with range() steps an LED from dark to bright and back, using PWM to fake the levels in between.25 min
  1. Run it
  2. range() does the counting
  3. while True: forever
  4. Make it breathe slower
Read a sensor with the ADCA knob on GP26 turns into a number with ADC, and that number sets the LED brightness. Then a little math turns it into a percent.25 min
  1. Run it
  2. Voltage in, number out
  3. Halfway is half bright
  4. Your own scale

Materials

  • LED
  • Potentiometer
  • Raspberry Pi Pico
  • Resistor

Check for understanding

Each student finishes "Read a sensor with the ADC" on their own, without opening the hints. The simulator checks 4 of its 4 steps as they go.

Then ask each one to explain, in a sentence or two, the last thing it asked of them: "Your own scale".

Chapter 3. About 50 min

Bigger programs

Lists and functions on an LED bar, and text on an OLED over I2C.

LessonTimeWhat students do
Lists and functions on an LED barSix LEDs in one list, and two small functions that turn a number into a moving dot or a growing bar.25 min
  1. Run it
  2. A function is a named job
  3. Spot the difference
  4. Write your own pattern
I2C to an OLED screenTwo wires carry a whole conversation: find the OLED and a weather sensor on I2C, then draw text on the screen.25 min
  1. Run it and scan
  2. Text on the screen
  3. Make it hot
  4. Your own screen

Materials

  • Full-size breadboard
  • LED x 6
  • OLED display, 128x64
  • Pressure, humidity and temperature, BME280
  • Raspberry Pi Pico
  • Resistor x 6

Check for understanding

Each student finishes "I2C to an OLED screen" on their own, without opening the hints. The simulator checks 4 of its 4 steps as they go.

Then ask each one to explain, in a sentence or two, the last thing it asked of them: "Your own screen".

Chapter 4. About 25 min

Boss game

A reaction timer with a random wait, a cheat catcher and a best score.

LessonTimeWhat students do
Boss game: reaction timerWait for the light, then hit the button. Functions, if, loops, random and the board clock come together in one game that keeps your best score.25 min
  1. Play it
  2. No cheating
  3. A best score
  4. Make it yours

Materials

  • LED
  • Pushbutton
  • Raspberry Pi Pico
  • Resistor

Check for understanding

Each student finishes "Boss game: reaction timer" on their own, without opening the hints. The simulator checks 4 of its 4 steps as they go.

Then ask each one to explain, in a sentence or two, the last thing it asked of them: "Make it yours".

Your class

Teach this unit as a class

Start a class from this course and its 7 lessons are assigned in one go, in order. Students join with a six-character code or printed login cards, and each one’s work comes back to you.

The class tools are free for 30 days for one class of up to 20 students, with no card. The lessons themselves are free either way.