-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain.go
79 lines (62 loc) · 1.14 KB
/
main.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
package main
// This is the most minimal blinky example and should run almost everywhere.
import (
"golitter/bts7960"
"machine"
"time"
)
/*
int R_IS = 1;
int R_EN = 2;
int R_PWM = 3;
int L_IS = 4;
int L_EN = 5;
int L_PWM = 6;
*/
const (
rEn = machine.D2
lEn = machine.D3
rPwm = machine.PD5
lPwm = machine.PD6
maxSpeed = 200
)
func blink(led machine.Pin) {
led.Low()
time.Sleep(time.Millisecond * 500)
led.High()
time.Sleep(time.Millisecond * 500)
}
func main() {
var period uint64 = 0
pwm := machine.Timer0
if err := pwm.Configure(machine.PWMConfig{Period: period}); err != nil {
println(err.Error())
return
}
println("starting...")
bts := bts7960.New(lEn, rEn, lPwm, rPwm, pwm)
err := bts.Configure()
if err != nil {
println("bts configure: " + err.Error())
return
}
led := machine.LED
led.Configure(machine.PinConfig{Mode: machine.PinOutput})
bts.Enable()
count := 0
for {
if count > 5 {
bts.Stop()
bts.Disable()
println("spinning done")
continue
}
println("main loop")
bts.Right(60)
blink(led)
count++
// for i := 0; i < maxSpeed; i++ {
// println("spin: " + strconv.Atoi)
// }
}
}