A one-file MicroPython library for the University of Toronto Department of Physics Analog Shield on a Phyduino Pico. Set-up steps are on the home page.
Copy analog_shield.py to the board next to your own main.py. It needs the Phyduino Pico firmware, which has phyduino.py built in:
Everything on the Phyduino Pico (mcu.pin(), mcu.pwm(), mcu.analog_volts(), ...) still works alongside; see the Phyduino Pico MicroPython reference.
Set these before plugging the shield in, for the Phyduino Pico's 3.3 V pins:
| Jumper | Set to | Does |
|---|---|---|
| JP3 (VIO) | 3.3 V | Pull-ups, LEDs and the potentiometer on 3.3 V, safe for the Phyduino's pins |
| JP4 | 5 V | The amplifier and sensor on the Arduino 5 V supply |
| JP1 | INT | The on-board LMT84 feeds the amplifier (EXT: the sensor on J1) |
| JP2 | EXT | The amplifier's output to A3 (INT: to A0; see set_output_pin()) |
JP3 and JP4 are solder jumpers and come open: bridge one side of each.
import analog_shield as shield
| Topic | Use |
|---|---|
| LEDs | green_led, red_led: Led.on(), Led.off(), Led.toggle(), Led.value() |
| Rotary encoder | encoder(): Encoder.position(), Encoder.set_position(), Encoder.steps(), Encoder.pressed(), Encoder.on_press() |
| Temperature and amplifier | temperature(), sensor_volts(), raw_sensor_volts(), amplifier_volts(), output_volts(), temperature_from_volts(), amplifier_gain(), amplifier_offset_volts(), set_output_pin(), set_supply_volts() |
| Potentiometer | pot_volts() |
| Version | version() |
Errors raise ValueError (a wrong setting) or OSError (the Phyduino's external ADC did not respond), with a message saying what to do.
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). The Standalone examples (examples/demo/ and examples/plotter/) are phyduino.py scripts with no arduino.py copy.