{"id":31202211,"url":"https://github.com/ipdotsetaf/ezbutton","last_synced_at":"2025-09-20T13:45:23.774Z","repository":{"id":182017518,"uuid":"666089966","full_name":"IPdotSetAF/EZButton","owner":"IPdotSetAF","description":"Arduino library that transforms raw button/touch inputs into events easily.","archived":false,"fork":false,"pushed_at":"2025-04-20T21:37:57.000Z","size":111,"stargazers_count":15,"open_issues_count":2,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-04-20T22:27:42.863Z","etag":null,"topics":["arduino","arduino-library","button","event","event-driven","platformio","touch"],"latest_commit_sha":null,"homepage":"","language":"C++","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"gpl-3.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/IPdotSetAF.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"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,"zenodo":null}},"created_at":"2023-07-13T17:27:15.000Z","updated_at":"2025-04-10T19:04:20.000Z","dependencies_parsed_at":null,"dependency_job_id":"00d9bf9e-5a90-415a-bad5-97eb3206d8fc","html_url":"https://github.com/IPdotSetAF/EZButton","commit_stats":null,"previous_names":["ipdotsetaf/ezbutton"],"tags_count":5,"template":false,"template_full_name":null,"purl":"pkg:github/IPdotSetAF/EZButton","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/IPdotSetAF%2FEZButton","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/IPdotSetAF%2FEZButton/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/IPdotSetAF%2FEZButton/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/IPdotSetAF%2FEZButton/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/IPdotSetAF","download_url":"https://codeload.github.com/IPdotSetAF/EZButton/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/IPdotSetAF%2FEZButton/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":276106025,"owners_count":25586190,"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","status":"online","status_checked_at":"2025-09-20T02:00:10.207Z","response_time":63,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"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":["arduino","arduino-library","button","event","event-driven","platformio","touch"],"created_at":"2025-09-20T13:45:18.114Z","updated_at":"2025-09-20T13:45:23.762Z","avatar_url":"https://github.com/IPdotSetAF.png","language":"C++","funding_links":[],"categories":[],"sub_categories":[],"readme":"\u003cp align=left\u003e\n   \u003ca href=\"https://registry.platformio.org/libraries/ipdotsetaf/EZButton\"\u003e\u003cimg src=\"https://img.shields.io/badge/dynamic/json?url=https%3A%2F%2Fapi.github.com%2Frepos%2FIPdotSetAF%2FEZButton%2Freleases%2Flatest\u0026query=%24.tag_name\u0026logo=data%3Aimage%2Fsvg%2Bxml%3Bbase64%2CPHN2ZyB3aWR0aD0iMjUwMCIgaGVpZ2h0PSIyNTAwIiB2aWV3Qm94PSIwIDAgMjU2IDI1NiIgeG1sbnM9Imh0dHA6Ly93d3cudzMub3JnLzIwMDAvc3ZnIiBwcmVzZXJ2ZUFzcGVjdFJhdGlvPSJ4TWlkWU1pZCI%20PHBhdGggZD0iTTEyOCAwQzkzLjgx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OS4zOTkgOS4zOTkgMCAwIDAgOS40IDkuNCA5LjM5OSA5LjM5OSAwIDAgMCA5LjM5OC05LjQgOS4zOTkgOS4zOTkgMCAwIDAtOS4zOTktOS4zOTl6bS0yLjgxIDguNjcxYTIuMzc0IDIuMzc0IDAgMSAxIDAtNC43NDggMi4zNzQgMi4zNzQgMCAwIDEgMCA0Ljc0OHoiIGZpbGw9IiNGRjdGMDAiLz48L3N2Zz4%3D\u0026label=PIO%20Registry\u0026color=orange\u0026link=https%3A%2F%2Fregistry.platformio.org%2Flibraries%2Fipdotsetaf%2FEZButton\"\u003e\u003c/a\u003e\n   \u003ca href=\"https://www.ardu-badge.com/EZButton\"\u003e\u003cimg src=\"https://www.ardu-badge.com/badge/EZButton.svg\"/\u003e\u003c/a\u003e\n   \u003cimg src=\"https://img.shields.io/github/v/release/IPdotSetAF/EZButton\"/\u003e\n   \u003cimg src=\"https://img.shields.io/github/release-date/IPdotSetAF/EZButton\"/\u003e\n   \u003cimg src=\"https://img.shields.io/github/last-commit/IPdotSetAF/EZButton\"/\u003e\n   \u003cimg src=\"https://img.shields.io/github/license/IPdotSetAF/EZButton\"/\u003e\n   \u003c!--\u003cimg src=\"https://img.shields.io/github/downloads/IPdotSetAF/EZButton/total\"/\u003e--\u003e\n\u003c/p\u003e\n\n# EZButton\nArduino library that transforms raw button/touch inputs into events easily.\n\nSubscribe to Pressed/Released/Hold/HoldReleased events with as many buttons as you want. Customize time thresholds and debouncing. Works with any button read method.\n\n\u003e [!IMPORTANT]\n\u003e If you found this library helpful, please consider leaving a Star⭐\n\u003e \n\u003e It helps a lot in maintaining the project ❤️\n\n## Features\n- Flexibility\n    - Works with:\n        - Buttons\n        - Touch\n        - Any other signal\n    - Also works with:\n        - Pulling\n        - Multiplexing\n        - Interrupts\n        - AnalogReads\n        - etc\n- Event Subscription: You can subscribe to any of the following events for any button:\n    - Pressed\n    - Released\n    - Hold\n    - Hold Released\n- Unlimited Buttons/Touches: You can configure as many buttons as you need.\n- Input signal Debouncing.\n- Customizability: You can change any of the time thresholds to customize your user experience.\n    - `HoldThreshold`: The time it takes before the first `HOLD` event is executed after the button is held down.\n    - `HoldInterval`: The Time Interval that corresponds to the `HOLD` event being executed repeatedly after the first `HOLD` event was registered.\n    - `DebounceTime`: The Time that is used to debounce input signal.\n- Debugging: Easily enable/disable logging for all button states and events.\n- Serial Output Customization: You can change the serial Output used for logging.\n- Blackout Time: Disable any event execution for the given amount of time.\n\n## How To\n### Installation\nThis Library is available in `Arduino Library Repository` and `PIO` and you can install it from: \n- Arduino IDE Library Manager\n\n![arduino library manager](image-1.png)\n\n- PlatformIO Libraries\n  \n![pltformio library](image.png)\n\n`ipdotsetaf/EZButton@^2.5.0`\n### Usage\n\n1. Include the library\n``` C++\n#include \u003cEZButton.h\u003e\n```\n2. Create an object from `EZButton`\n``` C++\n#define BTN_1 0\n#define BTN_2 1\n#define BTN_3 2\n#define BTN_4 3\n//config for 4 buttons\n//Read button states from the 'ReadButtons' function\n//HoldThreshold: 500ms\n//HoldInterval: 300ms\n//DebounceTime: 15ms\nEZButton _ezb(4, ReadButtons, 500, 300, 15);\n```\n3. Initialize your buttons/touches however you want.\n4. Attach any Interrups if needed.\n5. Subscribe to any event you need\n``` C++\n//Define your pinModes\n//...\n\n//button event subscribtion\n//button index, function to execute, event type\n_ezb.Subscribe(BTN_1, Btn1HoldRelease, HOLD_RELEASED);\n_ezb.Subscribe(BTN_2, Btn2Release, RELEASED);\n_ezb.Subscribe(BTN_3, Btn3Hold, HOLD);\n_ezb.Subscribe(BTN_3, Btn3Release, RELEASED);\n_ezb.Subscribe(BTN_4, Btn4Hold, HOLD);\n_ezb.Subscribe(BTN_4, Btn4Release, RELEASED);\n\n//or you can pass lambda functions\n_ezb.Subscribe(BTN_4, []() {\n    //...\n    }, HOLD);\n_ezb.Subscribe(BTN_4, [](int index) {\n    //index will be the index of the button triggering the event\n    //...\n    }, RELEASED);\n``` \n\u003e [!IMPORTANT]\n\u003e `button index` stands for an array inside EZButton that holds your button states and IS NOT PIN of the button.\n\n6. Define `ReadButtons` function\n``` C++\nvoid ReadButtons(bool *states, int num)\n{\n\t//Read all button states however you want\n\tstates[BTN_1] = !digitalRead(2);\n\tstates[BTN_2] = touchRead(3) \u003c= 50;\n\tstates[BTN_3] = touchRead(4) \u003c= 50;\n\tstates[BTN_4] = touchRead(5) \u003c= 50;\n}\n```\n7. Call EZButtons `Loop()` function in your main loop.\n``` C++\nvoid loop()\n{\n\t//...\n\n\t_ezb.Loop();\n}\n```\n8. Define Event Functions that was used in Subscriptions (step 5)\n``` C++\nvoid Btn1HoldRelease(){\n    //...\n}\n\n// you can also get the button index\nvoid Btn2Release(int index){\n    //...\n}\n//...\n```\n### Debugging\n\u003e [!TIP]\n\u003e To enable debugging, you need to add the `-DEZBUTTON_DEBUG` parameter to your `build_flags`.\n\u003e \n\u003e This will log event subscriptions and event executions to the serial.\n\n\u003e [!TIP]\n\u003e If you are using another `Serial` port, you can override the default serial by adding the `-DEZBUTTON_SerialOutput=Serial1` Build Flag to your environment.\n\n\u003e [!IMPORTANT]\n\u003e Right now only one subscription is possible for each button event.\n\u003e\n\u003e e.g. You can only subscribe to the `PRESSED` event of `BTN_2` once and the second subscription to this event will override the last one.\n\u003e\n\u003e You can still subscribe to other events with the same button with no problem. \n\n## Example\n\nPlease refer to this [Fully working example](https://github.com/IPdotSetAF/EZButton/blob/main/examples/Blink/Blink.ino)\n\n## TODO:\n- Rewrite in C \n- Add multiple subscriptions to a single event\n\n## Contribution\n- You can open Issues for any bug report or feature request.\n- You are free to contribute to this project by following these steps:\n   1. Fork this Repo.\n   2. Create a new branch for your feature/bugfix in your forked Repo.\n   3. Commit your changes to the new branch you just made.\n   4. Create a pull request from your branch into the `main` branch of This Repo([https://github.com/IPdotSetAF/EZButton](https://github.com/IPdotSetAF/EZButton)).\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fipdotsetaf%2Fezbutton","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fipdotsetaf%2Fezbutton","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fipdotsetaf%2Fezbutton/lists"}