Skip to content

analogWrite() Notes and Warnings in reference section #774

Open
@cattledogGH

Description

@cattledogGH

The reference section for analogWrite() https://www.arduino.cc/reference/en/language/functions/analog-io/analogwrite/ includes this material in "notes and warning"

Notes and Warnings
The PWM outputs generated on pins 5 and 6 will have higher-than-expected duty cycles. This is because of interactions with the millis() and delay() functions, which share the same internal timer used to generate those PWM outputs. This will be noticed mostly on low duty-cycle settings (e.g. 0 - 10) and may result in a value of 0 not fully turning off the output on pins 5 and 6.

Since analogWrite(pin,0) will be executed as digitalWrite(pin,LOW) I do not think that this statement is correct and it should be removed.

may result in a value of 0 not fully turning off the output on pins 5 and 6.

I would like to see some explanation of the "higher than expected duty cycles on pins 5 and 6". How big an effect is this, and is it worth a special warning? If indeed it is a significant issue, then the statement should be broadened to deal with the output pins on Timer 0 which are different than 5 and 6 on platforms other than the AT328.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions