runtime: Implement GPIO output

Now we can actually blink a LED!
This commit is contained in:
Ayke van Laethem
2018-04-27 01:29:13 +02:00
parent 5bbd41e9fb
commit 3a4663150e
5 changed files with 66 additions and 4 deletions
+11 -4
View File
@@ -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)
}
}