Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Undefined behaviour (bug) in button debouncing tutorial code #10

Open
Labels
@mrexodia

Description

@mrexodia

The documentation page:https://www.arduino.cc/en/Tutorial/Debounce has an error in thecode.

The variablebuttonState at line 40 is uninitialized which will cause undefined behaviour the first time line 75if (reading != buttonState) is executed.

Usually (based on testing)buttonState is not equal toreading which results in detection of a button press on startup that did not happen. Sincereading isHIGH when the button is not pressed, the correct initial value forbuttonState is alsoHIGH. When changing this, the example functions correctly and the LED is on after the program started.

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


      [8]ページ先頭

      ©2009-2025 Movatter.jp