analogWrite DAC only once for each pinMode( ,OUTPUT)

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?