← MicroPython on Pi Pico and Projects
Project 1.4 & 1.5 Companion
Project 1.4 & 1.5 Checklist
Name: Period: Date:
Check off each box as you finish that step. The back is a quick reference for the syntax, not the challenges themselves, you still have to figure those out.
Project 1.4: Blinking and Counting
| Step | ✓ |
|---|---|
| Onboard LED blinks, from a saved script | |
| One of my own wired LEDs blinks (pin used: ) | |
| Challenge: leds.py saved with a working unarycount(leds, delay) function | |
| Challenge: binarycount(leds, delay) added to leds.py |
Project 1.5: Fading with PWM
| Step | ✓ |
|---|---|
| Tried duty_u16() at 0, 32768, and 65535 in the REPL | |
| Challenge: breathe1(led) added to leds.py | |
| Challenge: breatheall(leds) added to leds.py |
Quick reference
Syntax only. The challenges above are still yours to work out: this page won’t do the converting or the looping for you.
Project 1.4
- Making an output pin:
machine.Pin(13, machine.Pin.OUT) - Unary: light as many LEDs as the count, no place value.
- Place values for 3 LEDs in binary: 4, 2, 1. Any number 0-7 is some combination of those three, on or off.
%(modulo) gives the remainder after dividing by something.//(floor division) divides by something and throws away the remainder.- Save both challenges in one file,
leds.py:unarycount(leds, delay=1)andbinarycount(leds, delay=1). Exact names: later projects import this file.
Project 1.5
- Making a PWM pin:
machine.PWM(machine.Pin(13)) - Setting its frequency:
led.freq(1000) - Setting brightness:
led.duty_u16(value), from0(off) to65535(fully on) range(start, stop, step)can step by more than 1, and count backward with a negative step- Add both challenges to the same
leds.pyfrom Project 1.4:breathe1(led)andbreatheall(leds). Exact names: later projects import this file.