Due is unable to DigitalWrite to a pin once AnalogWrite has occurred

Due is unable to DigitalWrite to a pin once Analog Write has occurred. Attached is a simple sketch. Please let me know if I am missing something. On Digital write it outputs 3.299 volts for 10 seconds then outputs pwm of 1.608 continuously. it will not produce a digital output once analog write occurs. I have tried this on 2 Dues. Works fine on Uno and Mega 2560.

void setup()
{
pinMode(4,OUTPUT);
}

void loop() {
digitalWrite(4, HIGH); // digital
delay (10000);

analogWrite(4,124); // PWS mode
delay (10000);

digitalWrite(4, HIGH); // digital
delay (10000);

}

Not to say the code shouldn't work, but as a newb I don't understand why you would want to do this. Just asking for some education.

As a workaround you may set the analog pin to the maximum:

analogWrite(4,255);

instead of:

digitalWrite(4, HIGH);

I don't understand why you would want to do this. Just asking for some education.

I would say that's just a test program konasilly has provided to show the problem.

As written thought it will provide a 10-second burst of PWM pulses every 30 seconds, that may make sense to an application somewhere, the world is a complicated place :slight_smile:

Let's say you wanted to flash a LED with that sequence and also control the brightness.


Rob