mirror of
https://github.com/kidoman/embd
synced 2025-07-03 03:47:33 +02:00
Added Package and sample for bh1750Fvi
This commit is contained in:
parent
65b32143cf
commit
2ac61dad95
2 changed files with 204 additions and 0 deletions
29
samples/bh1750Fvi.go
Normal file
29
samples/bh1750Fvi.go
Normal 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("H", bus)
|
||||
|
||||
defer lightingSensor.Close()
|
||||
|
||||
for {
|
||||
lighting, err := lightingSensor.Lighting()
|
||||
if err != nil {
|
||||
log.Panic(err)
|
||||
}
|
||||
log.Printf("Lighting is %v", lighting, "lx")
|
||||
time.Sleep(500 * time.Millisecond)
|
||||
}
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue