-
-
Notifications
You must be signed in to change notification settings - Fork 2
/
main.go
46 lines (37 loc) · 767 Bytes
/
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
package main
import (
"fmt"
"machine"
"time"
"tinygo.org/x/drivers/buzzer"
)
type note struct {
tone float64
duration float64
}
func main() {
//led := machine.LED
led := machine.LCD_BACKLIGHT
led.Configure(machine.PinConfig{Mode: machine.PinOutput})
cnt := 0
bzrPin := machine.WIO_BUZZER
bzrPin.Configure(machine.PinConfig{Mode: machine.PinOutput})
bzr := buzzer.New(bzrPin)
notes := []note{
{buzzer.C3, buzzer.Quarter},
{buzzer.D3, buzzer.Quarter},
{buzzer.E3, buzzer.Quarter},
}
for {
cnt++
fmt.Printf("cnt %d\r\n", cnt)
led.Low()
time.Sleep(time.Millisecond * 500)
led.High()
time.Sleep(time.Millisecond * 500)
for _, n := range notes {
bzr.Tone(n.tone, n.duration)
time.Sleep(10 * time.Millisecond)
}
}
}