The Photon, P1, Electron, and E Series support true analog output on pins DAC (
A6 in code) and A3 (
A3 in code). Using
with these pins, the output of the pin is set to an analog voltage from 0V to 3.3V that corresponds to values
NOTE: This output is buffered inside the STM32 to allow for more output current at the cost of not being able to achieve rail-to-rail performance, i.e., the output will be about 50mV when the DAC is set to 0, and approx 50mV less than the 3V3 voltage when DAC output is set to 4095.
NOTE: Device OS version 0.4.6 and 0.4.7 only - not applicable to versions from 0.4.9 onwards: While for PWM pins one single call to
pinMode(pin, OUTPUT); sets the pin mode for multiple
analogWrite(pin, value); calls, for DAC pins you need to set
pinMode(DAC, OUTPUT); each time you want to perform an
// SYNTAX pinMode(DAC1, OUTPUT); analogWrite(DAC1, 1024); // sets DAC pin to an output voltage of 1024/4095 * 3.3V = 0.825V.
Gen 3 Devices (B Series SoM, Tracker SoM, Tracker One, Boron, Argon, and E404X):
DAC is not supported on the P2, Photon 2, or Gen 3 devices (Argon, Boron, B Series SoM, Tracker SoM).