Repository navigation
Analog Shield library release v0.1.0
AnalogShield v0.1.0
First release of the Arduino library for the U of T Physics Analog Shield (Rev-C), used in the
Introduction to Electronics course. Developed for the Phyduino Pico (RP2040, board package
phyduino_bsp v0.1.0-alpha.1 or later); also builds for the Arduino Uno R3 and Uno R4 Minima.
Install: download AnalogShield-0.1.0.zip from this release, then in the Arduino IDE use
Sketch → Include Library → Add .ZIP Library…
Documentation: https://perc-sw.github.io/analog_shield_lib/
Library
- Pin map:
AnalogShieldPinsconstants for every shield signal, using Arduino pin names, from the
Rev-C schematic. - Rotary encoder: counted with interrupts from
begin();EncoderCount(),EncoderDetents(),
SetEncoderCount(), and an optional per-step callback (SetEncoderCallback()). - Encoder switch:
SwitchPressed()and an optional press/release callback (SetSwitchCallback()). - Temperature (LMT84):
TempRaw(),TempMillivolts(),TempCelsius(),TempFahrenheit()and
TempKelvin(), on the raw sensor (SENSOR), the conditioned signal for the MCU ADC (MCU) or for an
external ADC (EXT). The shield's signal conditioning is undone before the LMT84 conversion. - Potentiometer:
PotRaw(),PotMillivolts()andPotPercent(). - ADC resolution:
SetAdcResolution()/AdcResolution(), 8 to 12 bits; millivolt and
temperature conversions follow it. - Averaging: every analog reading takes an optional
samplescount to average several ADC reads. - LEDs:
LedON()andLedToggle()for D1 (green) and D2 (red); both LEDs are active low, and the
library handles that. - Version:
ANALOG_SHIELD_VERSION("0.1.0") andANALOG_SHIELD_VERSION_MAJOR/_MINOR/
_PATCH, so a sketch can check which library version it was built with.
Examples
| Example | Shows |
|---|---|
EncoderPolling |
Reading the encoder and switch from loop() |
EncoderInterrupt |
The same, with callbacks |
Temperature |
LMT84 temperature as an ADC reading, mV, °C, °F and K |
SerialPlotter |
Encoder, potentiometer and temperatures in the Serial Plotter; the switch selects the MCU or EXT channel |
LedFade |
PWM fading of D1 and D2 |