{"id":16238159,"url":"https://github.com/hieromon/pseudopwm","last_synced_at":"2026-04-29T01:33:53.816Z","repository":{"id":96638143,"uuid":"111052121","full_name":"Hieromon/PseudoPWM","owner":"Hieromon","description":"Output pseudo PWM wave for Arduino","archived":false,"fork":false,"pushed_at":"2018-02-01T06:37:12.000Z","size":10,"stargazers_count":3,"open_issues_count":0,"forks_count":1,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-04-08T08:50:16.461Z","etag":null,"topics":["arduino-library","esp8266","pwm","ticker","timer"],"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/Hieromon.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE.md","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}},"created_at":"2017-11-17T03:20:18.000Z","updated_at":"2022-11-06T09:07:17.000Z","dependencies_parsed_at":null,"dependency_job_id":"c749a23b-57a8-4fe8-8965-3381a728eb93","html_url":"https://github.com/Hieromon/PseudoPWM","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/Hieromon/PseudoPWM","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Hieromon%2FPseudoPWM","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Hieromon%2FPseudoPWM/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Hieromon%2FPseudoPWM/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Hieromon%2FPseudoPWM/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/Hieromon","download_url":"https://codeload.github.com/Hieromon/PseudoPWM/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Hieromon%2FPseudoPWM/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":32407164,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-04-28T19:38:08.556Z","status":"ssl_error","status_checked_at":"2026-04-28T19:37:55.688Z","response_time":56,"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-library","esp8266","pwm","ticker","timer"],"created_at":"2024-10-10T13:39:06.073Z","updated_at":"2026-04-29T01:33:53.802Z","avatar_url":"https://github.com/Hieromon.png","language":"C++","funding_links":[],"categories":[],"sub_categories":[],"readme":"# PseudoPWM for Arduino\n*Output pseudo PWM wave to arduino digital port.*\n\n[![Build Status](https://travis-ci.org/Hieromon/PseudoPWM.svg?branch=master)](https://travis-ci.org/Hieromon/PseudoPWM)\n\nIt generates a relatively long cycle pseudo PWM as milliseconds and output to the port.\n\n## Features\n\n* Specify cycle and duty in millisecond unit\n* Change cycle and duty dynamically\n* Suspend output and resume\n* It uses two ticker objects\n\n## Works on\n\nIt uses two Ticker objects. Useally Ticker class depends on the hardware timers equipped on the various Arduino boards. Hardware timers are implemented as Timer libraries and eventually work as Ticker's reality.\nTherefore, whether the PseudoPWM works properly depends on the Arduino board. However, ESP8266 works correctly.\n\n## Installation\n\nDownload this file as a zip, and extract the resulting folder into your Arduino Libraries folder.  \nSee ![Installing Additional Arduino Libraries](https://www.arduino.cc/en/Guide/Libraries).\n\n## Example\n\n- Simple\n\n```c++\n// This sketch blinks simply the onboard LED of ESP8266.\n\n#include \u003cArduino.h\u003e\n#include \"PseudoPWM.h\"\n\nPseudoPWM PilotLED(2);\n\nvoid setup() {\n  PilotLED.Start(1000, 500);\n}\n\nvoid loop() {\n  delay(100);\n}\n```\n\n- Change duty rate dynamically\n\n```c++\n// This sketch flashes the onboard LED of ESP8266.\n// Also it is blinked 0.2 seconds for one second every 8 seconds.\n\n#include \u003cArduino.h\u003e\n#include \"PseudoPWM.h\"\n\nPseudoPWM PilotLED(2);              // ESP8266 onboard led is active-low\nunsigned  long ts;\nboolean   flash;\n\nvoid setup() {\n  PilotLED.Start(2000, 1700);       // Start PWM, lit for 0.3[s]\n  flash = false;\n  ts = millis(); \n}\n\nvoid loop() {\n  unsigned long ls = millis();\n  unsigned long span = ls - ts;\n\n  delay(500);\n  if (span \u003e 1000) {\n    if (flash) {\n      PilotLED.Start(2000, 1700);   // Restore cycle and duty\n      digitalWrite(2, HIGH);        // turn off led\n      flash = false;\n    }\n    if (span \u003e 8000) {\n      PilotLED.Start(200, 100);     // Change cycle and duty to blinking 0.2[s]\n      flash = true;\n      ts = ls;\n    }\n  }\n}\n```\n\n## Usage\n\n### Declare PseudoPWM object\n```c++\n#include \"PseudoPWM.h\"\n\nPseudoPWM pwmout(uint8_t port);\n```\nSpecify the port to output PWM. Output mode of the port is set to DIGITAL OUT in the constructor.\nIncidentally, Ticker.h is also included from PseudoPWM.h.\n\n### Methods\n\n#### Start()\n```c++\nvoid PseudoPWM::Start(unsigned int cycle, unsigned int duty);\n```\nStarts PWM output. Specify cycle for the PWM cycle and duty for  duty of PWM by millisecond unit.\n\n#### Stop()\n```c++\nvoid PseudoPWM::Stop();\n```\nStop PWM output. It only temporarily stops output and the timer is running. From this state, the output can be resumed by the Start method.\n\n#### attach()\n```c++\nvoid PseudoPWM::attach(void(*callback)(void));\n```\nThe function attached here is called every cycle period. \n```c++\nPseudoPWM pwmout(2);\n\nvoid callbackOne() {\n  // This is called every second. \n  Serial.println(\"Cycle tick.\");\n}\n\nvoid setup() {\n  pwmout.attach(callbackOne);\n  pwmout.Start(1000, 100);\n}\n\nvoid loop() {\n  ...\n}\n```\n#### detach()\n```c++\nvoid PseudoPWM::detach();\n```\nDisable callback.\n\nLicense\n-----------\nThe PseudoPWM class is licensed under the [MIT License](LICENSE.md).  \nCopyright \u0026copy; 2017 hieromon@gmail.com\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fhieromon%2Fpseudopwm","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fhieromon%2Fpseudopwm","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fhieromon%2Fpseudopwm/lists"}