mirror of
https://github.com/tinygo-org/tinygo.git
synced 2026-08-04 11:07:46 +00:00
runtime: Implement GPIO output
Now we can actually blink a LED!
This commit is contained in:
@@ -1,14 +1,21 @@
|
||||
|
||||
package main
|
||||
|
||||
import "runtime"
|
||||
import (
|
||||
"machine"
|
||||
"runtime"
|
||||
)
|
||||
|
||||
func main() {
|
||||
led := machine.GPIO{17} // LED 1 on the PCA10040
|
||||
led.Configure(machine.GPIOConfig{Mode: machine.GPIO_OUTPUT})
|
||||
for {
|
||||
// TODO: enable/disable actual LED
|
||||
println("LED on")
|
||||
runtime.Sleep(runtime.Millisecond * 250)
|
||||
led.Set(false)
|
||||
runtime.Sleep(runtime.Millisecond * 500)
|
||||
|
||||
println("LED off")
|
||||
runtime.Sleep(runtime.Millisecond * 250)
|
||||
led.Set(true)
|
||||
runtime.Sleep(runtime.Millisecond * 500)
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user