mirror of
https://github.com/kidoman/embd
synced 2024-12-22 12:50:19 +01:00
1b6c346d40
the ambient temperature
24 lines
310 B
Go
24 lines
310 B
Go
package main
|
|
|
|
import (
|
|
"log"
|
|
"time"
|
|
|
|
"github.com/kid0m4n/go-rpi/sensor/us020"
|
|
)
|
|
|
|
func main() {
|
|
rf := us020.New(10, 9, nil)
|
|
defer rf.Close()
|
|
|
|
for {
|
|
distance, err := rf.Distance()
|
|
if err != nil {
|
|
log.Panic(err)
|
|
}
|
|
log.Printf("Distance is %v", distance)
|
|
|
|
time.Sleep(500 * time.Millisecond)
|
|
}
|
|
}
|