tinygo.org/x/drivers@v0.27.1-0.20240509133757-7dbca2a54349/examples/delay/delay.go (about)

     1  package main
     2  
     3  import (
     4  	"time"
     5  
     6  	"tinygo.org/x/drivers/delay"
     7  )
     8  
     9  func main() {
    10  	time.Sleep(time.Second) // wait for a serial console
    11  	start := time.Now()
    12  	for i := 0; i < 2000; i++ {
    13  		delay.Sleep(50 * time.Microsecond)
    14  	}
    15  	duration := time.Since(start)
    16  	println("sleep of 2000*50µs (100ms) took:", duration.String())
    17  }