1
0
Fork 0
mirror of https://github.com/kidoman/embd synced 2025-07-03 11:57:38 +02:00
This commit is contained in:
Kashyap Kopparam 2013-12-23 16:52:58 +05:30
commit 1746e906fe
3 changed files with 209 additions and 3 deletions

29
samples/bh1750fvi.go Normal file
View file

@ -0,0 +1,29 @@
package main
import (
"log"
"time"
"github.com/kid0m4n/go-rpi/i2c"
"github.com/kid0m4n/go-rpi/sensor/bh1750fvi"
)
func main() {
bus, err := i2c.NewBus(1)
if err != nil {
log.Panic(err)
}
lightingSensor := bh1750fvi.New(bh1750fvi.High, bus)
defer lightingSensor.Close()
for {
lighting, err := lightingSensor.Lighting()
if err != nil {
log.Panic(err)
}
log.Printf("Lighting is %v lx", lighting)
time.Sleep(500 * time.Millisecond)
}
}