{"id":13802395,"url":"https://github.com/larsks/micropython-stepper-motor","last_synced_at":"2025-07-05T11:35:13.268Z","repository":{"id":66821071,"uuid":"323422454","full_name":"larsks/micropython-stepper-motor","owner":"larsks","description":null,"archived":false,"fork":false,"pushed_at":"2020-12-24T04:29:09.000Z","size":8,"stargazers_count":11,"open_issues_count":0,"forks_count":4,"subscribers_count":4,"default_branch":"master","last_synced_at":"2025-04-09T23:42:13.495Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/larsks.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null}},"created_at":"2020-12-21T18:54:05.000Z","updated_at":"2025-03-24T23:15:49.000Z","dependencies_parsed_at":null,"dependency_job_id":"c74044c3-8a5e-4afe-9809-c4d5041bc99c","html_url":"https://github.com/larsks/micropython-stepper-motor","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/larsks%2Fmicropython-stepper-motor","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/larsks%2Fmicropython-stepper-motor/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/larsks%2Fmicropython-stepper-motor/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/larsks%2Fmicropython-stepper-motor/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/larsks","download_url":"https://codeload.github.com/larsks/micropython-stepper-motor/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248511799,"owners_count":21116469,"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":[],"created_at":"2024-08-04T00:01:43.453Z","updated_at":"2025-04-12T03:28:41.011Z","avatar_url":"https://github.com/larsks.png","language":"Python","funding_links":[],"categories":["Libraries"],"sub_categories":["Motion"],"readme":"# MicroPython Stepper Motor Driver\n\nCode to drive a 28BYJ-48 motor attached to a ULN2003 driver.\n\n## Overview\n\nThe module `motor.py` implements the following classes:\n\n- `FullStepMotor` -- This class drives a stepper motor using full steps, which\n  with the 28BYJ-48 means 2048 steps for a single rotation.\n\n- `HalfStepMotor` -- This class drives a stepper motor using half steps, so\n  4096 steps for a single rotation.\n\n## API\n\nMotor objects support the following methods:\n\n- `zero()` -- set the current position as position 0.\n- `step(n)` -- move forward (positive `n`) or backwards (negative `n`) the given number of steps\n- `step_until(position)` -- move motor to the given position. By default the motor will move in the shortest direction, but you can force a direction with the optional `dir` keyword argument (`1` for forward, `-1` for reverse).\n- `step_until_angle(angle)` -- move motor to the given angle.\n\n## Examples\n\nIf you have a ULN2003 connected to a Wemos D1 on pins D5, D6, D7, D8,\nlike this ([pinout][]):\n\n[pinout]: https://escapequotes.net/esp8266-wemos-d1-mini-pins-and-diagram/\n\n| Wemos pin   | ULN2003 pin |\n| ----------- | ----------- |\n| D5 (GPIO14) | IN1 |\n| D6 (GPIO12) | IN2 |\n| D7 (GPIO13) | IN3 |\n| D8 (GPIO15) | IN4 |\n\nThen you could create a `HalfStepMotor` object like this:\n\n```\nimport motor\nm = motor.HalfStepMotor.frompins(14,12,13,15)\n```\n\nOnce you have a motor object, you can run it forward:\n\n```\nm.step(500)\n```\n\nOr backwards:\n\n```\nm.step(-500)\n```\n\nYou can run it to a specific position:\n\n```\nm.step_until(2000)\n```\n\nOr to a specific angle:\n\n```\nm.step_until_angle(270)\n```\n\nWhen using the `step_until*` methods, the motor will by default move\nin the direction of shortest distance. You can force a direction with\nthe optional `dir` keyword argument:\n\n```\nm.step_until(2000, dir=-1)\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Flarsks%2Fmicropython-stepper-motor","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Flarsks%2Fmicropython-stepper-motor","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Flarsks%2Fmicropython-stepper-motor/lists"}