mirror of
https://github.com/tinygo-org/drivers.git
synced 2026-07-26 10:38:41 +00:00
5d3ad4ba52
The package with the main function should always have the name main. This was not the case in three packages. This was silently allowed before, but since a TinyGo change (https://github.com/tinygo-org/tinygo/pull/1592) this now results in a linker failure. Perhaps this should result in a better error message in TinyGo. However, the example code also needs to be fixed, so hence this PR.
21 lines
291 B
Go
21 lines
291 B
Go
package main
|
|
|
|
import (
|
|
"machine"
|
|
"time"
|
|
|
|
"tinygo.org/x/drivers/hcsr04"
|
|
)
|
|
|
|
func main() {
|
|
sensor := hcsr04.New(machine.D10, machine.D9)
|
|
sensor.Configure()
|
|
|
|
println("Ultrasonic starts")
|
|
for {
|
|
println("Distance:", sensor.ReadDistance(), "mm")
|
|
|
|
time.Sleep(100 * time.Millisecond)
|
|
}
|
|
}
|