github.com/aykevl/tinygo@v0.5.0/src/examples/blinky2/blinky2.go (about) 1 package main 2 3 // This blinky is a bit more advanced than blink1, with two goroutines running 4 // at the same time and blinking a different LED. The delay of led2 is slightly 5 // less than half of led1, which would be hard to do without some sort of 6 // concurrency. 7 8 import ( 9 "machine" 10 "time" 11 ) 12 13 func main() { 14 go led1() 15 led2() 16 } 17 18 func led1() { 19 led := machine.GPIO{machine.LED} 20 led.Configure(machine.GPIOConfig{Mode: machine.GPIO_OUTPUT}) 21 for { 22 println("+") 23 led.Low() 24 time.Sleep(time.Millisecond * 1000) 25 26 println("-") 27 led.High() 28 time.Sleep(time.Millisecond * 1000) 29 } 30 } 31 32 func led2() { 33 led := machine.GPIO{machine.LED2} 34 led.Configure(machine.GPIOConfig{Mode: machine.GPIO_OUTPUT}) 35 for { 36 println(" +") 37 led.Low() 38 time.Sleep(time.Millisecond * 420) 39 40 println(" -") 41 led.High() 42 time.Sleep(time.Millisecond * 420) 43 } 44 }