tinygo.org/x/drivers@v0.27.1-0.20240509133757-7dbca2a54349/examples/i2csoft/adt7410/main.go (about)

     1  package main
     2  
     3  import (
     4  	"fmt"
     5  	"machine"
     6  	"time"
     7  
     8  	"tinygo.org/x/drivers/adt7410"
     9  	"tinygo.org/x/drivers/i2csoft"
    10  )
    11  
    12  func main() {
    13  	i2c := i2csoft.New(machine.SCL_PIN, machine.SDA_PIN)
    14  	i2c.Configure(i2csoft.I2CConfig{
    15  		Frequency: 400e3,
    16  	})
    17  
    18  	sensor := adt7410.New(i2c)
    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  }