File tree 2 files changed +35
-0
lines changed
2 files changed +35
-0
lines changed Original file line number Diff line number Diff line change
1
+ package main
2
+
3
+ import (
4
+ "fmt"
5
+ "machine"
6
+ "time"
7
+
8
+ "tinygo.org/x/drivers/max6675"
9
+ )
10
+
11
+ // example for reading temperature from a thermocouple
12
+ func main () {
13
+ // Pins are for an Adafruit Feather nRF52840 Express
14
+ machine .D5 .Configure (machine.PinConfig {Mode : machine .PinOutput })
15
+ machine .D5 .High ()
16
+
17
+ machine .SPI0 .Configure (machine.SPIConfig {
18
+ Frequency : 1_000_000 ,
19
+ SCK : machine .SPI0_SCK_PIN ,
20
+ SDI : machine .SPI0_SDI_PIN ,
21
+ })
22
+
23
+ thermocouple := max6675 .NewDevice (machine .SPI0 , machine .D5 )
24
+
25
+ for {
26
+ temp , err := thermocouple .Read ()
27
+ if err != nil {
28
+ println (err )
29
+ return
30
+ }
31
+ fmt .Printf ("%0.02f C : %0.02f F\n " , temp , (temp * 9 / 5 )+ 32 )
32
+ time .Sleep (time .Second )
33
+ }
34
+ }
Original file line number Diff line number Diff line change @@ -139,6 +139,7 @@ tinygo build -size short -o ./build/test.uf2 -target=pico ./examples/mcp9808/mai
139
139
tinygo build -size short -o ./build/test.uf2 -target=pico ./examples/tmc2209/main.go
140
140
tinygo build -size short -o ./build/test.hex -target=pico ./examples/tmc5160/main.go
141
141
tinygo build -size short -o ./build/test.uf2 -target=nicenano ./examples/sharpmem/main.go
142
+ tinygo build -size short -o ./build/test.hex -target=feather-nrf52840 ./examples/max6675/main.go
142
143
# network examples (espat)
143
144
tinygo build -size short -o ./build/test.hex -target=challenger-rp2040 ./examples/net/ntpclient/
144
145
# network examples (wifinina)
You can’t perform that action at this time.
0 commit comments