mirror of
https://github.com/kidoman/embd
synced 2025-07-03 11:57:38 +02:00
Merge branch 'master' of https://github.com/kid0m4n/go-rpi
This commit is contained in:
commit
1746e906fe
3 changed files with 209 additions and 3 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(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)
|
||||
}
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue