Loading...
Searching...
No Matches
phyduino.py examples

Example scripts for the Phyduino Pico that use phyduino.py (import phyduino as mcu), in examples/phyduino/, written the usual MicroPython way: the set-up code at the top of the file runs once, then a while True: loop runs over and over. Analogue readings are 12-bit (0-4095) and PWM duty is 0-65535.

The examples are in folders named after the Arduino IDE's example categories, with board-specific ones in phyduino_pico/. Each example is a main.py in its own folder, because MicroPython runs main.py each time the board starts. Each page below explains what the script does, how to wire it and what it prints, followed by its source. The same examples written with arduino.py are on the arduino.py examples page.

With the Phyduino Pico firmware on the board, run a script from PyCharm, or with mpremote run examples/phyduino/<folder>/<name>/main.py. To have it run every time the board starts, copy its main.py to the board: mpremote cp examples/phyduino/<folder>/<name>/main.py :, then press RESET.

01_basics
Example What it shows
Bare Minimum The empty program to start from
Blink Blinking the on-board LED
Analog Read Serial All six analogue pins as 12-bit codes
Digital Read Serial Printing the state of a pushbutton
Fade Fading the on-board LED with PWM
Read Analog Voltage All six analogue pins in millivolts
02_digital
Example What it shows
Blink Without Delay Timing with time.ticks_ms() instead of time.sleep()
Button Lighting the LED while a pushbutton is pressed
Debounce Ignoring contact bounce so each press counts once
Digital Input Pullup A pushbutton with the pin's own pull-up resistor
State Change Detection Counting presses by detecting the edge
Tone Melody Playing a tune on a piezo buzzer
Tone Pitch Follower A pitch that follows an analogue input
03_analog
Example What it shows
Analog In Out Serial Setting LED brightness from a potentiometer
Calibration Learning a sensor's range at start-up
Smoothing A running average of the last 10 readings
04_communication
Example What it shows
ASCII Table Characters with their decimal, hex, octal and binary values
Graph Sending readings to a serial plotter
I2C Scanner Finding the devices on the I2C bus
Physical Pixel Switching the LED from the computer
UART Loopback Sending and receiving on UART0
phyduino_pico
Features of this board that the Arduino examples have no match for.
Example What it shows
Analog Averaging How the averaging setting steadies a reading
Analog Differential The voltage between two pins
VBUS Monitor The USB-C supply voltage and the CPU temperature
USB-PD Power Asking a USB-PD charger for a higher voltage