analogWrite not switching to digitalWrite

I am using an MKR WAN 1300 board.

According to the reference: analogWrite() - Arduino Reference

After a call to analogWrite(), the pin will generate a steady square wave of the specified duty cycle until the next call to analogWrite() (or a call to digitalRead() or digitalWrite()) on the same pin.

In my case, when I use analogWrite it ignores my subsequent digitalWrite.

Here is my test case. It does not turn off my LED, which I have attached to pin 5.

void setup() {
// put your setup code here, to run once:
pinMode(5, OUTPUT);

analogWrite(5, 10);
digitalWrite(5, LOW);

void loop() {
// put your main code here, to run repeatedly:


Hi gerrikoio,

It's the pinMode() function that configures the pin back to digital GPIO.

Just place the line:

pinMode(5, OUTPUT);

...after the delay() function.

Thanks, adding the pinMode again worked.