arduino / arduino/ArduinoCore-samd

digitalWrite ignored after calling analogWrite on PWM pin

Open
#385 4 comments 0 reactions 1 assignee Claimed by @Rocketct View on GitHub
bug
Dominant language
C
Stars
502
Forks
740
PR merge metrics
No merged PRs in 30d

Description

Calls to digitalWrite don't do anything after calling analogWrite on a PWM pin. Tested on the MKR1000 and MKR WiFi 1010 with SAMD 1.6.20 core.

```
const int ledPin = 5;
unsigned long wait = 10 * 1000;
bool analog = false;

void setup() {
Serial.begin(9600);

// Comment the next line to NOT wait for a serial connection for debugging
while (!Serial);

// initialize digital pin 5 as an output.
pinMode(ledPin, OUTPUT);

digitalWrite(ledPin, HIGH);
Serial.println("Blinking with digitalWrite");
}

void loop() {
Serial.println("on");
digitalWrite(ledPin, HIGH);
delay(1000);
Serial.println("off");
digitalWrite(ledPin, LOW);
delay(1000);

if (millis() > wait && !analog) {
Serial.println("analogWrite will break sketch");
analogWrite(ledPin, 0xF);
analog = true;
}
}
```
The Arduino 101 had a similar issue that was fixed https://github.com/arduino/ArduinoCore-arc32/issues/280

Contributor guide

No contributing guide indexed for this repository

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.