mirror of
https://github.com/tinygo-org/drivers.git
synced 2026-08-06 16:03:41 +00:00
693e7a1db7
* Added driver for BH1750 digital ambient light sensor
23 lines
320 B
Go
23 lines
320 B
Go
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)
|
|
}
|
|
}
|