embd/samples/bh1750fvi.go

30 lines
464 B
Go
Raw Normal View History

2013-12-17 16:07:58 +01:00
package main
import (
"log"
"time"
"github.com/kid0m4n/go-rpi/i2c"
2013-12-20 21:22:36 +01:00
"github.com/kid0m4n/go-rpi/sensor/bh1750fvi"
2013-12-17 16:07:58 +01:00
)
func main() {
bus, err := i2c.NewBus(1)
if err != nil {
log.Panic(err)
}
2013-12-20 21:22:36 +01:00
lightingSensor := bh1750fvi.New(bh1750fvi.High, bus)
2013-12-17 16:07:58 +01:00
defer lightingSensor.Close()
for {
lighting, err := lightingSensor.Lighting()
if err != nil {
log.Panic(err)
}
log.Printf("Lighting is %v lx", lighting)
2013-12-17 16:07:58 +01:00
time.Sleep(500 * time.Millisecond)
}
}