{"id":21223905,"url":"https://github.com/niklauslee/servo","last_synced_at":"2025-03-15T01:33:57.243Z","repository":{"id":77037186,"uuid":"460375909","full_name":"niklauslee/servo","owner":"niklauslee","description":"Kaluma library to control servo motors","archived":false,"fork":false,"pushed_at":"2022-02-17T11:05:34.000Z","size":51,"stargazers_count":2,"open_issues_count":0,"forks_count":0,"subscribers_count":2,"default_branch":"main","last_synced_at":"2025-01-21T17:30:38.859Z","etag":null,"topics":["kaluma","motor","servo"],"latest_commit_sha":null,"homepage":"","language":"JavaScript","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/niklauslee.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}},"created_at":"2022-02-17T09:57:33.000Z","updated_at":"2024-10-03T16:15:17.000Z","dependencies_parsed_at":null,"dependency_job_id":"caa78aa0-6af9-4761-81ff-9e0b78d73242","html_url":"https://github.com/niklauslee/servo","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/niklauslee%2Fservo","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/niklauslee%2Fservo/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/niklauslee%2Fservo/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/niklauslee%2Fservo/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/niklauslee","download_url":"https://codeload.github.com/niklauslee/servo/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":243671781,"owners_count":20328694,"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":["kaluma","motor","servo"],"created_at":"2024-11-20T22:54:00.778Z","updated_at":"2025-03-15T01:33:57.224Z","avatar_url":"https://github.com/niklauslee.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Servo\n\nKaluma library to control servo motors. It uses PWM internally, so the servo should be wired to a PWM-capable pin.\n\n# Wiring\n\nHere is a wiring example with SG90.\n\n| Raspberry Pi Pico | SG90 |\n| ----------------- | ---- |\n| VBUS              | +    |\n| GND               | -    |\n| GP15              | IN   |\n\n![wiring](https://github.com/niklauslee/servo/blob/main/images/wiring.jpg?raw=true)\n\n# Install\n\n```sh\nnpm install https://github.com/niklauslee/servo\n```\n\n# Usage\n\nHere is an example:\n\n```js\nconst {Servo} = require('servo');\nconst servo = new Servo();\n\n// attach to GP15\nservo.attach(15);\n\n// Turn from 0 to 180 by 10 degrees\nfor (let i = 0; i \u003c= 180; i = i+10) {\n  servo.write(i);\n  delay(500);\n}\n```\n\n# API\n\n## Class: Servo\n\n### new Servo()\n\nCreate an instance of Servo class.\n\n### attach(pin[, min, max, period])\n\n- **`pin`** `\u003cnumber\u003e` A pin for control.\n- **`min`** `\u003cnumber\u003e` Pulse width in microseconds for the minimum degree (e.g. 0 angle). Default: `544`.\n- **`max`** `\u003cnumber\u003e` Pulse width in microseconds for the maximum degree (e.g. 180 angle). Default: `2400`.\n- **`period`** `\u003cnumber\u003e` Period in microseconds. Default: `20000`.\n\nAttach the instance to a PWM pin. \n\nIf you want to use multiple servo motors, you need to check [PWM slices and channels](https://docs.kaluma.io/boards/raspberry-pi-pico#pwm).\n\n### detach()\n\nDetach the instance from the PWM pin;\n\n### write(angle)\n\n- **`angle`** `\u003cnumber\u003e`\n\nMove the servo as the angle (0 ~ 180).\n\n### read()\n\n- **Return** `\u003cnumber\u003e`\n\nReturns the current angle of the servo (0 ~ 180).\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fniklauslee%2Fservo","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fniklauslee%2Fservo","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fniklauslee%2Fservo/lists"}