Loading...
Searching...
No Matches
Analog Shield Library

CI Version Licence

Arduino library and examples for the Analog Shield used in the University of Toronto, Department of Physics, "[Introduction to Electronics](https://perc-sw.github.io/intro_to_electronics/)" course.

The library uses only the standard Arduino API, plus analogFullScaleMillivolts() on the Phyduino Pico. It is developed for the Phyduino Pico (board package phyduino_bsp v0.1.0-rc.2 or later) and also builds for the Arduino Uno.

Documentation: https://perc-sw.github.io/analog_shield_lib/

Install

Download AnalogShield-<version>.zip from the latest release, then in the Arduino IDE use Sketch → Include Library → Add .ZIP Library…. Examples appear under File → Examples → AnalogShield.

To build the ZIP from a local checkout, run extras/make-zip.sh (writes build/AnalogShield-<version>.zip from the last commit; pass a tag or commit to package that instead).

Every CI run also keeps a ZIP of that build for 30 days, as a workflow artifact named AnalogShield-<version>+<run number>.<commit>.zip (open the run under Actions, then Artifacts). Use it to try a change before it is released.

Versions

Releases use MAJOR.MINOR.PATCH (for example 0.1.0), with -rc.N for release candidates (for example 0.1.1-rc.1). A sketch can check the installed version with ANALOG_SHIELD_VERSION (the full string) or ANALOG_SHIELD_VERSION_MAJOR, _MINOR and _PATCH.

To release, set the same version in library.properties, ANALOG_SHIELD_VERSION and its parts in src/AnalogShield.h, and PROJECT_NUMBER in Doxyfile (CI checks they match), add a CHANGELOG.md section, then publish a GitHub release tagged v<version>. The release workflow attaches the library ZIP.

Examples

Open them from File → Examples → AnalogShield. Each sketch's header comment lists the jumper settings it needs and what it prints.

Example Shows Output
EncoderPolling Reading the encoder count and switch from loop() Serial Monitor
EncoderInterrupt The same, with encoder and switch callbacks Serial Monitor
Temperature LMT84 temperature as an ADC reading, mV, °C, °F and K Serial Monitor
SerialPlotter Encoder, potentiometer and temperatures live; the switch selects the MCU or EXT channel, shown on D1/D2 Serial Plotter
plotter Port of the MicroPython plotter example: both temperatures, encoder clicks, channel, potentiometer and VBUS; the switch selects A0 or A3, shown on D1/D2. Phyduino Pico only Serial Plotter
LedFade Fading D1 and D2 in and out with PWM (analogWrite()) LEDs only

Examples that print use 115200 baud.

Pin map

Pin Name Signal
A0 TEMP_SIG_MCU Conditioned temperature signal (JP2 at Internal: RP2040 ADC)
A1 SENSOR_IN Raw temperature sensor (JP1: Internal on-board U1 or External J1)
A3 TEMP_SIG_EXT Conditioned temperature signal (JP2 at External: MAX11635 ADC on the Phyduino Pico)
A4 IR_VOUT Sharp GP2Y0A21YK0F IR distance sensor (J2)
A5 POT Potentiometer RV1
D2 ENC_SW Rotary encoder switch, active low
D3 ENC_A Rotary encoder A, active low
D4 ENC_B Rotary encoder B, active low
D5 LED2 Red LED (silkscreen D2), active low
D6 LED1 Green LED (silkscreen D1), active low

Set JP3 (VDD) to 3.3 V when using a 3.3 V board such as the Phyduino Pico.

Repository layout

library.properties Arduino library metadata
keywords.txt IDE syntax colouring
src/ Library source
examples/ Example sketches (each compiled by CI)
tests/ PC-side unit tests (doctest + fake Arduino API)
CMakeLists.txt CMake project: library target and tests (not used by the Arduino IDE)
docs/ GitHub Pages site (reference material)
.github/workflows/ CI

Tests

PC-side unit tests compile the real src/ code against a fake Arduino.h (tests/fake_arduino/) that records pin modes and levels. From the repo root:

cmake --workflow --preset host-tests

Needs a C++17 compiler (GCC or Clang; on Windows, MSYS2 UCRT64), CMake 3.21 or later, Ninja and internet access the first time (doctest is downloaded at configure time). Add tests as tests/test_*.cpp; they are picked up automatically.