kopia lustrzana https://github.com/zhcong/ULN2003-for-ESP32
commit
efe3ba6f17
|
@ -5,9 +5,9 @@ import Stepper
|
||||||
from machine import Pin
|
from machine import Pin
|
||||||
s1 = Stepper.create(Pin(16,Pin.OUT),Pin(17,Pin.OUT),Pin(5,Pin.OUT),Pin(18,Pin.OUT), delay=2)
|
s1 = Stepper.create(Pin(16,Pin.OUT),Pin(17,Pin.OUT),Pin(5,Pin.OUT),Pin(18,Pin.OUT), delay=2)
|
||||||
s1.step(100)
|
s1.step(100)
|
||||||
s1.step(100,-1)
|
s1.step(100,-1) # or s1.step(-100)
|
||||||
s1.angle(180)
|
s1.angle(180)
|
||||||
s1.angle(360,-1)
|
s1.angle(360,-1) # or s1.angle(-360)
|
||||||
```
|
```
|
||||||
function `angle` is angle, and the PIN map:
|
function `angle` is angle, and the PIN map:
|
||||||
`IN1` link `PIN_16`
|
`IN1` link `PIN_16`
|
||||||
|
@ -15,4 +15,4 @@ function `angle` is angle, and the PIN map:
|
||||||
`IN3` link `PIN_5`
|
`IN3` link `PIN_5`
|
||||||
`IN4` link `PIN_18`
|
`IN4` link `PIN_18`
|
||||||
My uln2003 board like this, and stepper runing:<br />
|
My uln2003 board like this, and stepper runing:<br />
|
||||||
![uln2003](img/uln2003.jpg) ![uln2003](img/stepper.gif)<br />
|
![uln2003](img/uln2003.jpg) ![uln2003](img/stepper.gif)<br />
|
||||||
|
|
|
@ -37,6 +37,9 @@ class Stepper:
|
||||||
|
|
||||||
def step(self, count, direction=1):
|
def step(self, count, direction=1):
|
||||||
"""Rotate count steps. direction = -1 means backwards"""
|
"""Rotate count steps. direction = -1 means backwards"""
|
||||||
|
if count<0:
|
||||||
|
direction = -1
|
||||||
|
count = -count
|
||||||
for x in range(count):
|
for x in range(count):
|
||||||
for bit in self.mode[::direction]:
|
for bit in self.mode[::direction]:
|
||||||
self.pin1(bit[0])
|
self.pin1(bit[0])
|
||||||
|
|
Ładowanie…
Reference in New Issue