Added driver for BH1750 digital ambient light sensor (#15)

* Added driver for BH1750 digital ambient light sensor
This commit is contained in:
Daniel Esteban
2019-02-08 09:04:58 +01:00
committed by Ron Evans
parent 31bc74101d
commit 693e7a1db7
3 changed files with 116 additions and 0 deletions
+22
View File
@@ -0,0 +1,22 @@
package main
import (
"time"
"machine"
"github.com/tinygo-org/drivers/bh1750"
)
func main() {
machine.I2C0.Configure(machine.I2CConfig{})
sensor := bh1750.New(machine.I2C0)
sensor.Configure()
for {
lux := sensor.Illuminance()
println("Illuminance:", lux, "lx")
time.Sleep(500 * time.Millisecond)
}
}