[{"element_type":"text","content":"\n  \n  \n  \n        \u003cp\u003eThis is a Python class for stepper motors: works with the current version of \u003ccode\u003egpiozero\u003c/code\u003e; works with 2-pin, 4-pin, 5-pin motors. The module is completely open-source and published here:\u003c/p\u003e\n\u003cul\u003e\n\u003cli\u003e\u003ca href=\"https://github.com/alecxcode/stepper\"\u003eGutHub repo with examples\u003c/a\u003e\u003c/li\u003e\n\u003c/ul\u003e\n\u003cp\u003eHow does it work? Place the \u003ccode\u003estepper.py\u003c/code\u003e file containing the \u003ccode\u003eStepper\u003c/code\u003e class in your project directory (or, for the async version, the \u003ccode\u003easync_stepper.py\u003c/code\u003e file with\u0026nbsp;\u003ccode\u003eAsyncStepper\u003c/code\u003e class). No need to install this library via \u003ccode\u003epip\u003c/code\u003e. However, \u003ccode\u003egpiozero\u003c/code\u003e shall be already installed in your system.\u003c/p\u003e\n      \n\n\n","metadata":{}},{"element_type":"embed","content":"https://www.youtube.com/watch?v=T8thjPohz5g"},{"element_type":"text","content":"\n        \u003cp\u003eThe library provides a class to control these motors.\u003c/p\u003e\n\u003cp\u003eFor instance, to rotate the motor 1024 steps, call:\u0026nbsp;\u003ccode\u003emotor.step(1024)\u003c/code\u003e (where motor is your step motor object).\u003c/p\u003e\n\u003cp\u003eThere is a non-blocking version that could be started before a loop or in a loop:\u0026nbsp;\u003ccode\u003emotor.start(steps_to_move)\u003c/code\u003e. Then each time in the loop call: \u003ccode\u003estep_motor.tick()\u003c/code\u003e.\u003c/p\u003e\n\u003cp\u003eOther methods set the speed, initialize the motor object, stop it. Async version can work in asynchronous programs.\u003c/p\u003e\n\u003cp\u003eBelow is an example of the code to control a stepper motor in a simple manner.\u003c/p\u003e\n      ","metadata":{}},{"element_type":"code","content":"# Non-blocking stepper example\nfrom stepper import Stepper\n\nmotor = Stepper(2048, 5, 6, 13, 19)\nmotor.set_speed(10)\nmotor.start(1024) # can call in the main loop as well on certain event\n\nwhile True:\n    t = motor.tick()\n    # run other commands while the motor works\n    # or sleep(max(t, 0.0001))\n    if motor.steps_left \u003c= 0:\n        break","metadata":{"language":"python","filename":"step_nonblock.py","linenums":false}},{"element_type":"product","content":"https://www.adafruit.com/product/5812","metadata":{"quantity":"1","description":"","name":"","url":"","featured":false}},{"element_type":"product","content":"https://www.adafruit.com/product/858","metadata":{"quantity":"1","description":"","name":"","url":"","featured":false}},{"element_type":"product","content":"https://www.adafruit.com/product/970","metadata":{"quantity":"1","description":"","name":"","url":"","featured":false}}]