Добавлен пример использования

This commit is contained in:
Victor Chapaev 2024-09-28 11:30:58 +03:00
parent 09835137a5
commit 18c8adf305
Signed by: victor
GPG Key ID: 05ACE065D1EC5CA4
2 changed files with 18 additions and 1 deletions

3
.gitignore vendored
View File

@ -1,2 +1,3 @@
go.sum
example
./example
!./cmd/*

16
cmd/example/example.go Normal file
View File

@ -0,0 +1,16 @@
package main
import (
"fmt"
"gitfox.ru/victor/go-dht"
"gitfox.ru/victor/go-wiringpi"
)
func main() {
if temp, hum, err := dht.ReadDHT(wiringpi.GPIO_7); err != nil {
fmt.Println(err)
} else {
ftemp := dht.CelsiumToFahrenheit(temp)
fmt.Printf("Temperature (C): %.1f\nTemperature (F): %.1f\nHumidity: %.1f\n", temp, ftemp, hum)
}
}