l9110x: add support for L9110x h-bridge motor driver

Signed-off-by: Ron Evans <ron@hybridgroup.com>
This commit is contained in:
Ron Evans
2020-01-03 10:31:35 +01:00
committed by Daniel Esteban
parent c6e8af3057
commit d5aa295b76
5 changed files with 175 additions and 1 deletions
+34
View File
@@ -0,0 +1,34 @@
package main
import (
"machine"
"time"
"tinygo.org/x/drivers/l9110x"
)
func main() {
wheel := l9110x.New(machine.D10, machine.D11)
wheel.Configure()
for i := 0; i <= 10; i++ {
println("Forward")
wheel.Forward()
time.Sleep(time.Millisecond * 1000)
println("Stop")
wheel.Stop()
time.Sleep(time.Millisecond * 1000)
println("Backward")
wheel.Backward()
time.Sleep(time.Millisecond * 1000)
println("Stop")
wheel.Stop()
time.Sleep(time.Millisecond * 1000)
}
println("Stop")
wheel.Stop()
}
+45
View File
@@ -0,0 +1,45 @@
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()
}