mirror of
https://github.com/tinygo-org/drivers.git
synced 2026-08-07 16:33:39 +00:00
Added driver for BH1750 digital ambient light sensor (#15)
* Added driver for BH1750 digital ambient light sensor
This commit is contained in:
committed by
Ron Evans
parent
31bc74101d
commit
693e7a1db7
@@ -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)
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user