Skip to content

millis() overflow problem.Β #52

@qnxsgwy

Description

@qnxsgwy

"if (msNow > nextSwitchTime) { nextSwitchTime = msNow + debounce;"
is used in the PID_RelayOutput example,
When nextSwitchTime overflows, the comparison results for the next cycle will be wrong.

//should use
if(millis() - lastMillis >= interval){
//and NOT like
if(millis() >= lastMillis + interval){

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions