Files
drivers/examples/easystepper/main.go
T
Neil Davis 8ddcd69ac0 Add support for '8-step mode' to easystepper
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.
2022-06-12 22:19:42 +02:00

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)
}
}