Closed
Description
If you call analogWrite on a PWM capable pin with any value other than 0 and 255, any subsequent calls to digitalWrite on the same pin are ignored until one of the following events occurs:
pinMode(PIN, OUTPUT)
is called on the pin again- You call
analogWrite(PIN, 0)
oranalogWrite(PIN, 255)
This behavior does not occur on the Arduino UNO.
Here is a simple sketch that illustrates the issue:
void setup() {
pinMode(9, OUTPUT);
}
void loop() {
digitalWrite(9, HIGH);
delay(1000);
analogWrite(9, 255/2);
delay(1000);
digitalWrite(9, LOW);
delay(1000);
}
On the 101
Once analogWrite(9, 255/2)
is called, pin 9 remains at a 50% duty cycle, ignoring all subsequent digitalWrite commands.
On the UNO
Pin 9 successfully switches between 100%, 50%, and 0% duty cycle.