Files
drivers/examples/adt7410/main.go
T
Ayke van Laethem 16d2b71820 all: do not use machine.TWI_FREQ_* constants
These constants were always a bit weird:

  * they use an uncommon name (TWI instead of I2C)
  * they don't follow Go naming conventions (CamelCase)
  * the constants don't provide much value: their name is their value
    (100KHZ => 100e3).

Therefore, I propose we remove them and replace them with regular
numeric constants.
2021-02-06 11:21:37 +01:00

28 lines
343 B
Go

package main
import (
"fmt"
"machine"
"time"
"tinygo.org/x/drivers/adt7410"
)
var (
i2c = &machine.I2C0
sensor = adt7410.New(i2c)
)
func main() {
i2c.Configure(machine.I2CConfig{Frequency: 400e3})
sensor.Configure()
for {
temp := sensor.ReadTempF()
fmt.Printf("temperature: %f\r\n", temp)
time.Sleep(time.Second)
}
}