{"id":17334872,"url":"https://github.com/tfeldmann/arduino-button","last_synced_at":"2025-03-27T07:11:26.201Z","repository":{"id":141241913,"uuid":"427047526","full_name":"tfeldmann/Arduino-Button","owner":"tfeldmann","description":null,"archived":false,"fork":false,"pushed_at":"2024-02-18T22:33:15.000Z","size":17,"stargazers_count":1,"open_issues_count":0,"forks_count":0,"subscribers_count":2,"default_branch":"main","last_synced_at":"2025-02-01T12:09:19.100Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"C++","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/tfeldmann.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":".github/FUNDING.yml","license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null},"funding":{"github":"tfeldmann","patreon":null,"open_collective":null,"ko_fi":"tfeldmann","tidelift":null,"community_bridge":null,"liberapay":null,"issuehunt":null,"otechie":null,"custom":"http://paypal.me/tfeldmann42"}},"created_at":"2021-11-11T15:19:44.000Z","updated_at":"2023-01-09T16:37:31.000Z","dependencies_parsed_at":"2024-02-18T23:30:10.286Z","dependency_job_id":"fe85f83d-c023-40fa-92a7-8eba6cdf44c7","html_url":"https://github.com/tfeldmann/Arduino-Button","commit_stats":null,"previous_names":[],"tags_count":1,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/tfeldmann%2FArduino-Button","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/tfeldmann%2FArduino-Button/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/tfeldmann%2FArduino-Button/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/tfeldmann%2FArduino-Button/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/tfeldmann","download_url":"https://codeload.github.com/tfeldmann/Arduino-Button/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":245798359,"owners_count":20673902,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-10-15T15:07:24.427Z","updated_at":"2025-03-27T07:11:26.173Z","avatar_url":"https://github.com/tfeldmann.png","language":"C++","funding_links":["https://github.com/sponsors/tfeldmann","https://ko-fi.com/tfeldmann","http://paypal.me/tfeldmann42"],"categories":[],"sub_categories":[],"readme":"# Arduino-Button\n\n[![PlatformIO Registry](https://badges.registry.platformio.org/packages/tfeldmann/library/Button.svg)](https://registry.platformio.org/libraries/tfeldmann/Button)\n\n## API\n\n```cpp\nstruct ButtonEvents {\n    bool pressed;\n    bool released;\n    bool changed;\n};\n\nclass VirtualButton {\n    VirtualButton(bool invert = false);\n    struct ButtonEvents update(bool reading);\n    bool is_pressed();\n    bool just_pressed();\n    bool just_released();\n    bool just_changed();\n}\n\nclass PinButton : public VirtualButton {\n    PinButton(int pin, int mode = INPUT_PULLUP, bool invert = false);\n};\n```\n\n## Button Events Example\n\n```cpp\n#include \u003cPinButton.h\u003e\n\nPinButton btn(12);\n\nvoid setup() {\n  Serial.begin(9600);\n}\n\nvoid loop() {\n  struct ButtonEvents evnt = btn.update();\n\n  if (evnt.pressed) Serial.println(\"Btn pressed\");\n  if (evnt.released) Serial.println(\"Btn released\");\n  if (evnt.changed) Serial.println(\"Btn changed\");\n}\n```\n\n## PinButton Example\n\nToggles a LED on pin 13 when the button is released.\n\n```cpp\n#include \u003cPinButton.h\u003e\n\nPinButton btn(12, INPUT_PULLUP);\nbool led_state = LOW;\n\nvoid setup()\n{\n    pinMode(13, OUTPUT); // LED\n    digitalWrite(13, led_state);\n}\n\nvoid loop()\n{\n    btn.update();\n    if (btn.just_released()) {\n        led_state = !led_state;\n        digitalWrite(13, led_state);\n    }\n}\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ftfeldmann%2Farduino-button","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Ftfeldmann%2Farduino-button","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ftfeldmann%2Farduino-button/lists"}