Replace Safe functions with legacy.PinOutput

This commit is contained in:
Yurii Soldak
2025-09-21 10:04:20 +02:00
parent c6d83b783f
commit 453ff96a66
16 changed files with 112 additions and 108 deletions
+5 -1
View File
@@ -1,14 +1,18 @@
//go:build baremetal && tinygo
package main
import (
"fmt"
"machine"
"time"
"tinygo.org/x/drivers/dht"
"tinygo.org/x/drivers/tinygo"
)
func main() {
pin := machine.D6
pin := tinygo.New(machine.D6)
dhtSensor := dht.New(pin, dht.DHT11)
for {
temp, hum, err := dhtSensor.Measurements()
+4 -1
View File
@@ -5,10 +5,13 @@ import (
"time"
"tinygo.org/x/drivers/hcsr04"
"tinygo.org/x/drivers/tinygo"
)
func main() {
sensor := hcsr04.New(machine.D10, machine.D9)
trigger := tinygo.New(machine.D10) // automatically configures pin as output
echo := tinygo.New(machine.D9) // automatically configures pin as input
sensor := hcsr04.New(trigger, echo)
sensor.Configure()
println("Ultrasonic starts")