mirror of
https://github.com/kidoman/embd
synced 2025-01-03 10:31:36 +01:00
27 lines
394 B
Go
27 lines
394 B
Go
package main
|
|
|
|
import (
|
|
"log"
|
|
"time"
|
|
|
|
"github.com/kidoman/embd/i2c"
|
|
"github.com/kidoman/embd/sensor/bh1750fvi"
|
|
)
|
|
|
|
func main() {
|
|
bus := i2c.NewBus(1)
|
|
|
|
sensor := bh1750fvi.New(bh1750fvi.High, bus)
|
|
defer sensor.Close()
|
|
|
|
for {
|
|
lighting, err := sensor.Lighting()
|
|
if err != nil {
|
|
log.Panic(err)
|
|
}
|
|
log.Printf("Lighting is %v lx", lighting)
|
|
|
|
time.Sleep(500 * time.Millisecond)
|
|
}
|
|
}
|