Skip to content

Error in IDE code example: 'Debounce' #5311

Closed
@OldSteve2

Description

@OldSteve2

In the 'Debounce' example provided with the IDE, under "File >Examples >Digital", the value of 'millis()' is stored in a 'long' variable type, which is not large enough:-

long lastDebounceTime = 0;  // the last time the output pin was toggled
// then:-
lastDebounceTime = millis();

It should be stored in an 'unsigned long'.
As a result of this error, many new users have picked up the same bad habit.
Is it possible to have that example modified, and 'long' replaced by 'unsigned long'?
This would save many new users from potential hard-to-detect problems if their code runs for long periods.

Thanks,
... Steve

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions