tinygo.org/x/drivers@v0.27.1-0.20240509133757-7dbca2a54349/examples/adt7410/main.go (about) 1 package main 2 3 import ( 4 "fmt" 5 "machine" 6 "time" 7 8 "tinygo.org/x/drivers/adt7410" 9 ) 10 11 var ( 12 i2c = machine.I2C0 13 sensor = adt7410.New(i2c) 14 ) 15 16 func main() { 17 18 i2c.Configure(machine.I2CConfig{Frequency: machine.TWI_FREQ_400KHZ}) 19 sensor.Configure() 20 21 for { 22 temp := sensor.ReadTempF() 23 fmt.Printf("temperature: %f\r\n", temp) 24 time.Sleep(time.Second) 25 } 26 27 }