Had trouble getting a little DAC demo running and finally found that I have to set the mode to output again before each analogWrite otherwise the DAC doesn’t get the new value. (Photon)
I have seen the issue with pinMode(DAC1, 4095) before each analogWrite and I have included this in some simple code
but do not measure any voltage output on DAC1. Does there need to be an external resistor (1k) to Gnd
Just to make sure, when you're using DAC1 you do measure on the pin that's labled DAC (and not A3 which would be DAC2)?
Just try - as mentioned above - this
void loop()
{
pinMode(DAC1, OUTPUT); // make sure to do it over and over again
analogWrite(DAC1, 4095);
digitalWrite(led, HIGH);
delay(5000);
pinMode(DAC1, OUTPUT);
analogWrite(DAC1, 0);
digitalWrite(led, LOW);
delay(5000);
}
Hey, I have similar kind of trouble with my photon. I can not use analogWrite() in my code, but it works with the tinker app. I’ve copied the code above and tried without success, any ideas?
There is an open issue about a regression in analogWrite()
When you use (or I guess used) Tinker this was still running on a previous system version and with a recent flash you got an auto-update causing these troubles.
You might have to downgrade or wait for the fix to be released.
That depends on the severeness of the underlying problem and the priority in the issues list.
Hard to say, but I’ve pinged Particles firmware genious to have another look.
Thanks, this worked for me. I could install my firmware with build target 0.4.5 via build.particle.io. Is there a possibility to set the build target in particle dev as well? It looks like it’s auto updating my device again once I try to flash via the Dev IDE.
I don’t think there is a way to set the target system version in Particle Dev, but I also think that Particle Dev does not cause an auto-update either, which might result in your application firmware not being able to run on your device if it’s not updated.
This is a muddle which I usually circumvent either by building locally or using Web IDE (Particle Build).
But maybe @suda got more background on that for you
The ide won’t update the firmware. Just click on devices icon (2nd from the bottom on the left), select your photon and in the details, select against which firmware you compile the code (0.4.5 instead of Latest).