Lesson plan

CircuitPython on the Pico lesson plan

Python on real hardware, from your first code.py: LEDs and buttons, knobs and PWM, NeoPixels, I2C sensors and an OLED with displayio, all on Adafruit’s official firmware, ending in a mood light you design.

4 chapters, 7 lessons, about 5 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

  • code.py, and pins that are on or off.
  • Analog readings, PWM and NeoPixels.
  • An I2C sensor and a screen.
  • A mood light built from the whole course.

Materials for the whole unit

  • Addressable RGB LEDs
  • LED
  • OLED display, 128x64
  • Potentiometer
  • Pressure, humidity and temperature, BME280
  • Pushbutton
  • Raspberry Pi Pico
  • Resistor

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 1 h 30 min

First steps

code.py, and pins that are on or off.

LessonTimeWhat students do
code.pyYour first CircuitPython program: print, a variable, a loop, and what happens when code.py ends. How the CIRCUITPY drive and auto-reload make every save a new run.45 min
  1. Run it: hello from Python
  2. A variable
  3. A loop
  4. When code.py ends
  5. Say your name
  6. On a real Pico
digitalioPins that are on or off: an LED as an output, a button as an input with a pull-up, blinking without sleep() so the button is never missed, and counting presses.45 min
  1. Run it: a blink and a button
  2. An output
  3. An input with a pull-up
  4. Count presses, not loops
  5. Blink faster
  6. Sleep or monotonic

Materials

  • Addressable RGB LEDs
  • LED
  • OLED display, 128x64
  • Potentiometer
  • Pressure, humidity and temperature, BME280
  • Pushbutton
  • Raspberry Pi Pico
  • Resistor

Check for understanding

Each student finishes "digitalio" on their own, without opening the hints. The simulator checks 6 of its 6 steps as they go.

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

Chapter 2. About 1 h 10 min

Knobs and light

Analog readings, PWM and NeoPixels.

LessonTimeWhat students do
analogio and pwmioBetween on and off: read a knob as a number from 0 to 65535 with analogio, turn it into volts, and dim an LED with pwmio by switching it on and off a thousand times a second.35 min
  1. Run it: a knob and a dimmer
  2. Turn it up
  3. Dim with PWM
  4. Turn it round
  5. Analog in, analog out
NeoPixelsEight color LEDs on one wire: colors as (red, green, blue) tuples, fill and single pixels, show() to send them all, brightness, and a chase in your own color.35 min
  1. Run it: all blue
  2. One pixel at a time
  3. A chase
  4. Your color
  5. Power

Materials

  • Addressable RGB LEDs
  • LED
  • OLED display, 128x64
  • Potentiometer
  • Pressure, humidity and temperature, BME280
  • Pushbutton
  • Raspberry Pi Pico
  • Resistor

Check for understanding

Each student finishes "NeoPixels" on their own, without opening the hints. The simulator checks 5 of its 5 steps as they go.

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

Chapter 3. About 1 h 20 min

Sense and show

An I2C sensor and a screen.

LessonTimeWhat students do
I2C sensorsTwo wires, many chips: scan the I2C bus for addresses, read temperature, humidity and pressure from a BME280 with Adafruit’s library, and turn Celsius into Fahrenheit.45 min
  1. Run it: who is on the bus?
  2. Read the BME280
  3. Warm it up
  4. Make it humid
  5. Fahrenheit
  6. Many chips, two wires
displayio basicsText on a 128 x 64 OLED with displayio: a display, a Group of Labels, the built-in terminal font, scale, and a counter that redraws itself when its text changes.35 min
  1. Run it: a screen
  2. Groups and labels
  3. Text that updates itself
  4. Your title
  5. One way for every screen

Materials

  • Addressable RGB LEDs
  • LED
  • OLED display, 128x64
  • Potentiometer
  • Pressure, humidity and temperature, BME280
  • Pushbutton
  • Raspberry Pi Pico
  • Resistor

Check for understanding

Each student finishes "displayio basics" on their own, without opening the hints. The simulator checks 5 of its 5 steps as they go.

Then ask each one to explain, in a sentence or two, the last thing it asked of them: "One way for every screen".

Chapter 4. About 1 h

Project

A mood light built from the whole course.

LessonTimeWhat students do
Project: a mood lightEverything together: a knob picks the color, a button steps through glow, breathe, rainbow and off, the BME280 turns it warm red when the room is hot, and the OLED says what it is doing.60 min
  1. Run it: a mood light
  2. Glow
  3. Change the mode
  4. Rainbow
  5. Pick a color
  6. Too hot
  7. Your own limit
  8. Build it for real

Materials

  • Addressable RGB LEDs
  • LED
  • OLED display, 128x64
  • Potentiometer
  • Pressure, humidity and temperature, BME280
  • Pushbutton
  • Raspberry Pi Pico
  • Resistor

Check for understanding

Each student finishes "Project: a mood light" on their own, without opening the hints. The simulator checks 8 of its 8 steps as they go.

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

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.