mirror of
https://github.com/tinygo-org/drivers.git
synced 2026-08-05 15:33:42 +00:00
d5aa295b76
Signed-off-by: Ron Evans <ron@hybridgroup.com>
46 lines
713 B
Go
46 lines
713 B
Go
package main
|
|
|
|
import (
|
|
"machine"
|
|
"time"
|
|
|
|
"tinygo.org/x/drivers/l9110x"
|
|
)
|
|
|
|
const (
|
|
maxSpeed = 30000
|
|
)
|
|
|
|
func main() {
|
|
machine.InitPWM()
|
|
|
|
wheel := l9110x.NewWithSpeed(machine.PWM{machine.D11}, machine.PWM{machine.D12})
|
|
wheel.Configure()
|
|
|
|
for i := 0; i <= 10; i++ {
|
|
println("Forward")
|
|
var i uint16
|
|
for i = 0; i < maxSpeed; i += 1000 {
|
|
wheel.Forward(i)
|
|
time.Sleep(time.Millisecond * 100)
|
|
}
|
|
|
|
println("Stop")
|
|
wheel.Stop()
|
|
time.Sleep(time.Millisecond * 1000)
|
|
|
|
println("Backward")
|
|
for i = 0; i < maxSpeed; i += 1000 {
|
|
wheel.Backward(i)
|
|
time.Sleep(time.Millisecond * 100)
|
|
}
|
|
|
|
println("Stop")
|
|
wheel.Stop()
|
|
time.Sleep(time.Millisecond * 1000)
|
|
}
|
|
|
|
println("Stop")
|
|
wheel.Stop()
|
|
}
|