2013-12-17 20:37:58 +05:30
|
|
|
package main
|
|
|
|
|
|
|
|
import (
|
|
|
|
"log"
|
|
|
|
"time"
|
|
|
|
|
|
|
|
"github.com/kid0m4n/go-rpi/i2c"
|
2013-12-21 01:52:36 +05:30
|
|
|
"github.com/kid0m4n/go-rpi/sensor/bh1750fvi"
|
2013-12-17 20:37:58 +05:30
|
|
|
)
|
|
|
|
|
|
|
|
func main() {
|
|
|
|
bus, err := i2c.NewBus(1)
|
|
|
|
if err != nil {
|
|
|
|
log.Panic(err)
|
|
|
|
}
|
|
|
|
|
2014-01-05 14:27:29 +05:30
|
|
|
sensor := bh1750fvi.New(bh1750fvi.High, bus)
|
|
|
|
defer sensor.Close()
|
2013-12-17 20:37:58 +05:30
|
|
|
|
|
|
|
for {
|
2014-01-05 14:27:29 +05:30
|
|
|
lighting, err := sensor.Lighting()
|
2013-12-17 20:37:58 +05:30
|
|
|
if err != nil {
|
|
|
|
log.Panic(err)
|
|
|
|
}
|
2013-12-20 00:43:40 +05:30
|
|
|
log.Printf("Lighting is %v lx", lighting)
|
|
|
|
|
2013-12-17 20:37:58 +05:30
|
|
|
time.Sleep(500 * time.Millisecond)
|
|
|
|
}
|
|
|
|
}
|