mirror of
https://github.com/tinygo-org/drivers.git
synced 2026-08-07 16:33:39 +00:00
Replace Safe functions with legacy.PinOutput
This commit is contained in:
@@ -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()
|
||||
|
||||
@@ -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")
|
||||
|
||||
Reference in New Issue
Block a user