Loading...
Searching...
No Matches
API reference

A one-file MicroPython library for the University of Toronto Department of Physics Phyduino Pico. Set-up steps are on the home page.

It is built into the Phyduino Pico firmware, so your own main.py can use it straight away:

import phyduino as mcu
mcu.led.on()
print(mcu.analog_volts("A3"))
button = mcu.pin("D2", "in", pull="up")

Everything else in MicroPython (time, machine.PWM, ...) works as described in the MicroPython documentation; use gpio() to find the RP2040 GPIO behind a pin name.

Functions

phyduino.py

import phyduino as mcu

Topic Use
Pins PINS, pin(), gpio(), pwm()
On-board LED On-board LED: Led.on(), Led.off(), Led.toggle(), Led.value()
Analog inputs analog_read(), analog_millivolts(), analog_volts(), analog_averaging(), analog_differential_millivolts(), analog_full_scale_millivolts(), ADC_FULL_SCALE_MILLIVOLTS, EXT_ADC_FULL_SCALE_MILLIVOLTS
Power and temperature vbus_volts(), cpu_temperature(), usb_pd(): STUSB4500.request(), STUSB4500.set_profiles(), STUSB4500.profiles(), STUSB4500.contract(), STUSB4500.contract_position(), STUSB4500.renegotiate()
Header buses i2c(), spi(), uart()
External ADC external_adc(): MAX11635.read(), MAX11635.scan(), MAX11635.read_differential(), MAX11635.set_averaging(), MAX11635.averaging
Version version()

arduino.py

from arduino import *, optional

Topic Use
Digital I/O pinMode(), digitalWrite(), digitalRead(), HIGH, LOW, INPUT, OUTPUT, INPUT_PULLUP, INPUT_PULLDOWN, LED_BUILTIN
Analog I/O analogRead(), analogReadResolution(), analogWrite(), analogWriteResolution(), analogWriteFreq(), A0-A5
Tones tone(), noTone()
Time delay(), delayMicroseconds(), millis(), micros()
Math map(), constrain()

Errors raise ValueError (a wrong pin name or setting) or OSError (an on-board chip did not respond), with a message saying what to do.

Examples

The Examples page lets you choose between the two sets of example scripts in examples/, which have the same examples: arduino.py examples (examples/arduino/, setup() and loop()) and phyduino.py examples (examples/phyduino/, plain MicroPython).