arduino / arduino/EduIntro

Button.pressed()?

Open
#2 3 comments 1 reaction 0 assignees View on GitHub
Dominant language
C++
Stars
40
Forks
11
PR merge metrics
No merged PRs in 30d

Description

Hi,

Would it make sense to introduce something like button.pressed() instead of readSwitch() ?
E.g. in https://github.com/arduino/EduIntro/blob/master/examples/by_topic/Button/Button.ino#L29

if (button.readSwitch() == LOW) { led.on(); } else { led.off(); }

if (button.pressed()) { led.on(); } else { led.off(); }

Or isPressed(), as in isPWM()

Kind regards,
Thomas

Contributor guide

Open the contributing guide

Research direction

Start with examples/by_topic/Button/Button.ino, especially the readSwitch() usage at line 29, then inspect the Button API to understand existing naming and switch behavior. Decide whether a pressed() or isPressed() API is appropriate and update the example and relevant coverage so the new behavior is clear.

Written by the indexing model from the issue text.

Assessment

Tech stack
cpp
Domain
embedded-iot
Issue type
Feature
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
30/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.