Difference between revisions of "Pi Pico driving steppers"

From MyWiki
Jump to: navigation, search
(Created page with "Reference:- https://www.youngwonks.com/blog/How-to-use-a-stepper-motor-with-the-Raspberry-Pi-Pico")
 
 
(2 intermediate revisions by the same user not shown)
Line 1: Line 1:
 
Reference:-  https://www.youngwonks.com/blog/How-to-use-a-stepper-motor-with-the-Raspberry-Pi-Pico
 
Reference:-  https://www.youngwonks.com/blog/How-to-use-a-stepper-motor-with-the-Raspberry-Pi-Pico
 +
<source lang="python">
 +
from machine import Pin
 +
import utime
 +
 +
pins = [
 +
    Pin(15,Pin.OUT),#IN1
 +
    Pin(14,Pin.OUT),#IN1
 +
    Pin(16,Pin.OUT),#IN1
 +
    Pin(17,Pin.OUT),#IN1
 +
      ]
 +
 +
full_step_sequence = [
 +
    [1,0,0,0],
 +
    [0,1,0,0],
 +
    [0,0,1,0],
 +
    [0,0,0,1]
 +
      ]
 +
 +
while True:
 +
    for step in full_step_sequence:
 +
        for i in range(len(pins)):
 +
            pins[i].value(step[i])
 +
            utime.sleep(0.001)
 +
 +
 +
</source>

Latest revision as of 09:17, 7 September 2023

Reference:- https://www.youngwonks.com/blog/How-to-use-a-stepper-motor-with-the-Raspberry-Pi-Pico

from machine import Pin
import utime
 
pins = [
    Pin(15,Pin.OUT),#IN1
    Pin(14,Pin.OUT),#IN1
    Pin(16,Pin.OUT),#IN1
    Pin(17,Pin.OUT),#IN1
       ]
 
full_step_sequence = [
    [1,0,0,0],
    [0,1,0,0],
    [0,0,1,0],
    [0,0,0,1]
      ]
 
while True:
    for step in full_step_sequence:
        for i in range(len(pins)):
            pins[i].value(step[i])
            utime.sleep(0.001)