mirror of
https://github.com/tinygo-org/drivers.git
synced 2026-07-26 10:38:41 +00:00
8ddcd69ac0
Currently, easystepper driver supports only '4-step mode' (12-23-34-41) when energizing the coils This does not work with all motors & drivers (e.g. 28BJY-48 & ULN2003) This commit adds support for 8-step mode (1-12-2-23-3-34-4-41) Note: this commit breaks backward source compatibility for the factory/constructor functions.
28 lines
507 B
Go
28 lines
507 B
Go
package main
|
|
|
|
import (
|
|
"machine"
|
|
"time"
|
|
|
|
"tinygo.org/x/drivers/easystepper"
|
|
)
|
|
|
|
func main() {
|
|
config := easystepper.DeviceConfig{
|
|
Pin1: machine.P13, Pin2: machine.P15, Pin3: machine.P14, Pin4: machine.P16,
|
|
StepCount: 200, RPM: 75, Mode: easystepper.ModeFour,
|
|
}
|
|
motor, _ := easystepper.New(config)
|
|
motor.Configure()
|
|
|
|
for {
|
|
println("CLOCKWISE")
|
|
motor.Move(2050)
|
|
time.Sleep(time.Millisecond * 1000)
|
|
|
|
println("COUNTERCLOCKWISE")
|
|
motor.Move(-2050)
|
|
time.Sleep(time.Millisecond * 1000)
|
|
}
|
|
}
|