-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.go
53 lines (44 loc) · 817 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
47
48
49
50
51
52
53
package main
import (
"machine"
"math/rand"
"time"
)
func main() {
defer func() {
if r := recover(); r != nil {
println(r)
}
}()
uart := machine.UART2
uart.Configure(machine.UARTConfig{
TX: machine.UART_TX_PIN,
RX: machine.UART_RX_PIN,
})
spi := machine.SPI0
spi.Configure(machine.SPIConfig{
SCK: machine.SCL_PIN,
MOSI: machine.D11,
})
led := machine.LED
led.Configure(machine.PinConfig{Mode: machine.PinOutput})
time.Sleep(time.Second * 5)
println("slept")
for {
led.High()
for i := 0; i < 64; i++ {
val := rand.Intn(256)
_, err := spi.Transfer(byte(val))
if err != nil {
println(err)
}
}
_, err := spi.Transfer(byte(12))
if err != nil {
println(err)
}
time.Sleep(time.Millisecond * 150)
led.Low()
time.Sleep(time.Millisecond * 150)
}
}