0

If I have:

analogWrite(4, 123);

Do I need to turn the PWM off like this:

analogWrite(4, 0);

If I'd like to set pin HIGH or LOW?

digitalWrite(4, HIGH);

In practice, changing pin HIGH/LOW works without turning PWM off but I'm encountering some unexpected behavior (my ESP8266 hangs) and I wonder if that could be the problem?

Defozo
  • 2,946
  • 6
  • 32
  • 51
  • This is interesting. Can/did you create as simple test program to determine if this behavior is reproducible? (I don't have the ability to do it myself at the moment) Also, I found something similar on github [here](https://github.com/esp8266/Arduino/issues/2175) – ContinuousLoad Oct 03 '17 at 16:37
  • I would make sure that you are using the most recent version of the arduino-esp8266 core -- just in case this is an old issue that has been fixed. I'll dig into this when I get a chance (or someone more knowledgeable than me will give an answer). – ContinuousLoad Oct 03 '17 at 16:44

1 Answers1

0

On my NodeMCU, once you call analogWrite on a pin, any later calls to digitalWrite have no effect; you're doomed to using analogWrite(pin, 0) or analogWrite(pin, PWMRANGE) which seems to work just fine.

ttzn
  • 2,543
  • 22
  • 26