I have a simple program which is using analogWrite to drive a voltmeter. When I use tinker, I can set the ouput range from 0-4095 and the voltmeter responds appropriately. From within my program, however, it seems to send 3.15V no matter what value I specify.
int patientMeter = A3;
I am using A3 because it uses the DAC to give a true voltage, not PWM.
void updateMeter() {
int analogValue = 0; // 0-4096 for analog write
if (include_obs) {
analogValue = admits_and_obs * 160;
} else {
analogValue = admits * 160;
}
pinMode(patientMeter, OUTPUT);
analogWrite(patientMeter, analogValue);
Particle.publish("updateMeter", String(analogValue));
}
Note that the publish command shows the correct value for analogValue
If it helps at all, the output was as expected when I used tinker.