{"id":16525523,"url":"https://github.com/andrewn/raspi-soft-pwm","last_synced_at":"2025-08-29T03:32:21.315Z","repository":{"id":66464817,"uuid":"67733395","full_name":"andrewn/raspi-soft-pwm","owner":"andrewn","description":null,"archived":false,"fork":false,"pushed_at":"2016-10-17T16:17:02.000Z","size":10,"stargazers_count":1,"open_issues_count":0,"forks_count":0,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-03-03T02:25:00.788Z","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/andrewn.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","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}},"created_at":"2016-09-08T19:21:34.000Z","updated_at":"2021-12-13T22:37:09.000Z","dependencies_parsed_at":null,"dependency_job_id":"e2a79639-1b50-4f7e-ab05-836541364673","html_url":"https://github.com/andrewn/raspi-soft-pwm","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/andrewn/raspi-soft-pwm","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/andrewn%2Fraspi-soft-pwm","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/andrewn%2Fraspi-soft-pwm/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/andrewn%2Fraspi-soft-pwm/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/andrewn%2Fraspi-soft-pwm/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/andrewn","download_url":"https://codeload.github.com/andrewn/raspi-soft-pwm/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/andrewn%2Fraspi-soft-pwm/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":272619368,"owners_count":24965415,"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-08-29T02:00:10.610Z","response_time":87,"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":[],"created_at":"2024-10-11T17:03:50.008Z","updated_at":"2025-08-29T03:32:21.246Z","avatar_url":"https://github.com/andrewn.png","language":"C++","funding_links":[],"categories":[],"sub_categories":[],"readme":"Raspi Soft PWM\n==============\n\nThis library provides support from node.js for managing software PWM on the Raspberry Pi. It uses the [Wiring Pi library](http://wiringpi.com/reference/software-pwm-library/) for the software PWM.\n\nThis library is almost entirely based on the excellent [Raspi-PWM](https://github.com/nebrius/raspi-pwm) by Bryan Hughes. That library lets you control the Raspberry Pi's single PWM pin.\n\nThis one lets you use any pin as a software PWM but make sure you read [Limitations](#limitations) below.\n\n## Installation\n\nFirst, be sure that you have installed [raspi](https://github.com/nebrius/raspi).\n\nInstall with NPM:\n\n```Shell\nnpm install raspi-soft-pwm\n```\n\n**Warning**: this module requires GCC 4.8 or newer. This means that you should be running Raspbian Jessie or newer, released in September of 2015.\n\n## Example Usage\n\n```JavaScript\nvar raspi = require('raspi');\nvar SoftPWM = require('raspi-soft-pwm').SoftPWM;\n\nraspi.init(function() {\n  var pwm = new SoftPWM({\n    pin: 7,\n    initialValue: 0,\n    range: 255\n  });\n  pwm.write(128); // set an LED to half brightness\n});\n```\n\n## Pin Naming\n\nThe pins on the Raspberry Pi are a little complicated. There are multiple headers on some Raspberry Pis with extra pins, and the pin numbers are not consistent between Raspberry Pi board versions.\n\nTo help make it easier, you can specify pins in three ways. The first is to specify the pin by function, e.g. ```'GPIO18'```. The second way is to specify by pin number, which is specified in the form \"P[header]-[pin]\", e.g. ```'P1-7'```. The final way is specify the [Wiring Pi virtual pin number](http://wiringpi.com/pins/), e.g. ```7```. If you specify a number instead of a string, it is assumed to be a Wiring Pi number.\n\nBe sure to read the [full list of pins](https://github.com/nebrius/raspi-io/wiki/Pin-Information) on the supported models of the Raspberry Pi.\n\n## Limitations\n\nSince the PWM isn't implemented in hardware, there are some limitations to be aware of when using the library.\n\nEvery SoftPWM pin you enable uses up about 0.5% of the CPU according to the [Wiring Pi software PWM documentation](uses approximately 0.5% of the CPU).\n\nYour program must continue running for the software PWM to continue outputting a signal.\n\n## API\n\n### new SoftPWM(config)\n\nInstantiates a new software PWM instance on the given pin.\n\n_Arguments_:\n\n\u003ctable\u003e\n  \u003cthead\u003e\n    \u003ctr\u003e\n      \u003cth\u003eArgument\u003c/th\u003e\n      \u003cth\u003eType\u003c/th\u003e\n      \u003cth\u003eDescription\u003c/th\u003e\n    \u003c/tr\u003e\n  \u003c/thead\u003e\n  \u003ctr\u003e\n    \u003ctd\u003econfig (optional)\u003c/td\u003e\n    \u003ctd\u003eNumber | String | Object\u003c/td\u003e\n    \u003ctd\u003eThe configuration for the software PWM pin. If the config is a number or string, it is assumed to be the pin number for the peripheral. If it is an object, the following properties are supported:\u003c/td\u003e\n  \u003c/tr\u003e\n  \u003ctr\u003e\n    \u003ctd\u003e\u003c/td\u003e\n    \u003ctd colspan=\"2\"\u003e\n      \u003ctable\u003e\n        \u003cthead\u003e\n          \u003ctr\u003e\n            \u003cth\u003eProperty\u003c/th\u003e\n            \u003cth\u003eType\u003c/th\u003e\n            \u003cth\u003eDescription\u003c/th\u003e\n          \u003c/tr\u003e\n        \u003c/thead\u003e\n        \u003ctr\u003e\n          \u003ctd\u003epin (optional)\u003c/td\u003e\n          \u003ctd\u003eNumber | String\u003c/td\u003e\n          \u003ctd\u003eThe pin number or descriptor for the peripheral\u003c/td\u003e\n        \u003c/tr\u003e\n        \u003ctr\u003e\n          \u003ctd\u003einitialValue (optional)\u003c/td\u003e\n          \u003ctd\u003eNumber\u003c/td\u003e\n          \u003ctd\u003eSets the initial value for the PWM on this pin.\u003c/td\u003e\n        \u003c/tr\u003e\n        \u003ctr\u003e\n          \u003ctd\u003erange (optional)\u003c/td\u003e\n          \u003ctd\u003eNumber\u003c/td\u003e\n          \u003ctd\u003eSets the maximum value that can be written to this pin.\u003c/td\u003e\n        \u003c/tr\u003e\n      \u003c/table\u003e\n    \u003c/td\u003e\n  \u003c/tr\u003e\n\u003c/table\u003e\n\n### Instance Properties\n\n#### range\n\nA number representing the maximum number that can be written to this pin using the `write(value)` instance method. This cannot be changed once you create a software PWM on a pin.\n\n\n### Instance Methods\n\n#### write(value)\n\nUpdates the PWM value for this pin.\n\n_Arguments_:\n\n\u003ctable\u003e\n  \u003cthead\u003e\n    \u003ctr\u003e\n      \u003cth\u003eArgument\u003c/th\u003e\n      \u003cth\u003eType\u003c/th\u003e\n      \u003cth\u003eDescription\u003c/th\u003e\n    \u003c/tr\u003e\n  \u003c/thead\u003e\n  \u003ctr\u003e\n    \u003ctd\u003evalue\u003c/td\u003e\n    \u003ctd\u003eNumber\u003c/td\u003e\n    \u003ctd\u003eThe value for the PWM to set, must be between 0 and `range`\u003c/td\u003e\n  \u003c/tr\u003e\n\u003c/table\u003e\n\n_Returns_: None\n\n\nLicense\n=======\n\nThe MIT License (MIT)\n\nCopyright (c) 2016 Andrew Nicolaou \u003cme@andrewnicolaou.co.uk\u003e\n\nPermission is hereby granted, free of charge, to any person obtaining a copy\nof this software and associated documentation files (the \"Software\"), to deal\nin the Software without restriction, including without limitation the rights\nto use, copy, modify, merge, publish, distribute, sublicense, and/or sell\ncopies of the Software, and to permit persons to whom the Software is\nfurnished to do so, subject to the following conditions:\n\nThe above copyright notice and this permission notice shall be included in\nall copies or substantial portions of the Software.\n\nTHE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\nIMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\nFITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\nAUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\nLIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\nOUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN\nTHE SOFTWARE.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fandrewn%2Fraspi-soft-pwm","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fandrewn%2Fraspi-soft-pwm","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fandrewn%2Fraspi-soft-pwm/lists"}