examples: clean up examples and add blinky1 for Arduino

Arduino has trouble supporting anything that's not extremely simple, so
add a simple blinky example for it. Also, it may be useful anyway.
This commit is contained in:
Ayke van Laethem
2018-09-05 11:49:31 +02:00
parent 17b5b6ec5b
commit 9101ea11bf
5 changed files with 35 additions and 7 deletions
+20
View File
@@ -0,0 +1,20 @@
package main
// This is the most minimal blinky example and should run almost everywhere.
import (
"machine"
"runtime"
)
func main() {
led := machine.GPIO{machine.LED}
led.Configure(machine.GPIOConfig{Mode: machine.GPIO_OUTPUT})
for {
led.Low()
runtime.Sleep(runtime.Millisecond * 500)
led.High()
runtime.Sleep(runtime.Millisecond * 500)
}
}
@@ -1,5 +1,10 @@
package main
// This blinky is a bit more advanced than blink1, with two goroutines running
// at the same time and blinking a different LED. The delay of led2 is slightly
// less than half of led1, which would be hard to do without some sort of
// concurrency.
import (
"machine"
"runtime"
@@ -1,5 +1,7 @@
package main
// This file is here to test features of the Go compiler.
import "unicode"
type Thing struct {