{"id":16991130,"url":"https://github.com/lnlp/easyled","last_synced_at":"2026-04-25T21:31:12.853Z","repository":{"id":110752270,"uuid":"354587603","full_name":"lnlp/EasyLed","owner":"lnlp","description":"Arduino library for controlling standard LEDs in an easy way. EasyLed provides simple logical methods like on(), off(), toggle(), flash(), isOn(), isOff() and reset(). This library will help to write cleaner code that is easy to read and understand.","archived":false,"fork":false,"pushed_at":"2021-11-20T12:32:16.000Z","size":23,"stargazers_count":1,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-05-31T11:35:34.876Z","etag":null,"topics":["arduino","arduino-library","blink","clean-architecture","clean-code","control","easy","easy-to-understand","easy-to-use","flash","led","led-control","leds","library"],"latest_commit_sha":null,"homepage":"","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/lnlp.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":"2021-04-04T16:07:15.000Z","updated_at":"2021-11-20T12:35:43.000Z","dependencies_parsed_at":"2024-03-08T20:25:22.782Z","dependency_job_id":null,"html_url":"https://github.com/lnlp/EasyLed","commit_stats":null,"previous_names":[],"tags_count":2,"template":false,"template_full_name":null,"purl":"pkg:github/lnlp/EasyLed","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/lnlp%2FEasyLed","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/lnlp%2FEasyLed/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/lnlp%2FEasyLed/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/lnlp%2FEasyLed/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/lnlp","download_url":"https://codeload.github.com/lnlp/EasyLed/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/lnlp%2FEasyLed/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":32278249,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-04-25T18:29:39.964Z","status":"ssl_error","status_checked_at":"2026-04-25T18:29:32.149Z","response_time":59,"last_error":"SSL_read: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"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","blink","clean-architecture","clean-code","control","easy","easy-to-understand","easy-to-use","flash","led","led-control","leds","library"],"created_at":"2024-10-14T03:24:55.907Z","updated_at":"2026-04-25T21:31:12.848Z","avatar_url":"https://github.com/lnlp.png","language":"C++","funding_links":[],"categories":[],"sub_categories":[],"readme":"# EasyLed  \n\n[![GitHub release](https://img.shields.io/github/release/lnlp/EasyLed.svg)](https://github.com/lnlp/EasyLed/releases/latest) [![GitHub commits](https://img.shields.io/github/commits-since/lnlp/EasyLed/v1.1.0.svg)](https://github.com/lnlp/EasyLed/compare/v1.1.0...main)\n\nArduino library for controlling standard LEDs in an easy way.\n\nEasyLed provides simple logical methods like `on()`, `off()`, `toggle()`, `flash()`, `isOn()`, `isOff()` and `reset()`.\u003cbr\u003e\nThis library will help to write cleaner code that is easy to read and understand.\n\nA LED can be switched On by simply using the statement **`led.on()`**. When someone reads that statement it is instantly clear what it does: switch the LED On. With EasyLed there is no need to use `pinMode()`, `digitalWrite()`, `HIGH` and `LOW` anymore.\n\nWithout EasyLed you will have to use a statement like `digitalWrite(LED_PIN, LOW)` to switch a LED On (if active-low). When reading that statement it does not become clear if it will switch the LED On or Off. This makes it more difficult to read and understand the code. You need to remember whether `HIGH` or `LOW` means the LED is On or Off. When both active-low *and* active-high LEDs are used that will make the code even more difficult to read and understand.\n\nLEDs are defined as instance of the `EasyLed` class. The constructor needs two parameters: `pin`, which is the GPIO pin the LED is connected to and `activeLevel` which indicates whether the LED is active-low or active-high. Enum value `EasyLed::ActiveLevel::Low` represents active-low and `EasyLed::ActiveLevel::High` represents active-high.\n\nFor On and Off states similar enum values are used: `EasyLed::State::On` means the LED is On and `EasyLed::State::Off` means it is Off. Enum values are used for state because neither `LOW` nor `HIGH` uniquely identify if a LED is On or Off.\n\nOptionally a third parameter `initialState` can be specified to set the initial state to On (default is Off).\nThe fourth parameter `pinmode` is also optional and sets the pin as output. This should normally not be changed\n_(except when there is reason to change it to OUTPUT_OPEN_DRAIN for architectures that support it)_.\n\n#### Active-low and active-high explained  \nLEDs are switched On and Off by programming the state of a GPIO pin. Setting the GPIO pin to a LOW level can turn a LED either On or Off. If the LED is On when the GPIO pin level is LOW this is called active-low. If the LED is On when the pin level is HIGH this is called active-high. Whether a LED is active-low or active-high depends on how the LED is physically connected. Both types are used in practice.\n\n### Constructor\n\n```cpp\nEasyLed(\n    const uint8_t pin,                      // GPIO pin to which the LED is connected.\n    const ActiveLevel activeLevel,          // The logic level when the LED is on.\n    const State initialState = State::Off,  // Optional, default is off.\n    const uint8_t pinmode = OUTPUT          // Optional, shall normally not be changed.      \n```   \n\n\n### Enumeration types\n\n```cpp\nenum class State {Off, On};\nenum class ActiveLevel {Low = LOW, High = HIGH};\n```\n\n\n### Functions\n\n```cpp\nvoid on()                                   // Switch LED on\n\nvoid off()                                  // Switch LED off\n\nvoid toggle()                               // Toggle LED state.\n\nvoid reset()                                // Reset LED state to initialState.\n\nvoid flash(                                 // Flash LED (all parameters are optional)\n    const uint8_t  count = 2,               // Number of flashes\n    const uint16_t onTimeMs = 160,          // on-time duration in milliseconds\n    const uint16_t offTimeMs = 160,         // off-time duration in milliseconds\n    const uint16_t leadOffTimeMs = 200,     // off-time duration before first flash\n    const uint16_t trailOffTimeMs = 300     // off-time duration after last flash\n                                            // lead and trail time are only used when LED is on\n)\n\nbool isOn()                                 // Returns true if LED is on, false otherwise\n\nbool isOff()                                // Returns true if LED is off, false otherwise\n\nEasyLed::State getState()                   // Returns the current state (On or Off)\n\nvoid setState(EasyLed::State state)         // Sets the current state\n\nuint8_t pin()                               // Returns GPIO pin number as specified in constructor\n\nEasyLed::ActiveLevel activeLevel()          // Returns active-level as specified in constructor\n\nEasyLed::State initialState()               // Returns initialState as specified in constructor\n```\n\n### Included examples\n\n- `led-basics.ino` - Demonstrates basic use\n- `led-advanced.ino` - Demonstrates more advanced use\n- `led-state.ino` - Demonstrates how to save and restore state\n- `led-activelevel-tester.ino` - Helps determine if LED is active-low or active-high\n\n\n### Simple code example\n\n```cpp\n#include \"EasyLed.h\"\n\nEasyLed led(LED_BUILTIN, EasyLed::ActiveLevel::Low);\n\nvoid setup() \n{\n    ...\n}  \n\nvoid loop() \n{ \n    readSensors();\n\n    led.on();\n    transmitSensorData();\n    led.off();\n\n    ...\n}\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Flnlp%2Feasyled","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Flnlp%2Feasyled","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Flnlp%2Feasyled/lists"}