Skip to content

Instantly share code, notes, and snippets.

@bketelsen
Created November 11, 2018 20:26
Show Gist options
  • Star 2 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save bketelsen/845f6fa382567303c2b788c4c444c3c6 to your computer and use it in GitHub Desktop.
Save bketelsen/845f6fa382567303c2b788c4c444c3c6 to your computer and use it in GitHub Desktop.
microbit cylon
package main
import (
"machine"
"time"
)
func main() {
machine.InitLEDMatrix()
left := machine.GPIO{machine.BUTTONA}
left.Configure(machine.GPIOConfig{Mode: machine.GPIO_INPUT})
var (
x uint8 = 2
y uint8 = 2
)
machine.ClearLEDMatrix()
var forward bool
for {
if forward {
if x == 4 {
forward = false
}
x++
} else {
if x == 0 {
forward = true
}
x--
}
machine.SetLEDMatrix(x, y)
time.Sleep(time.Millisecond * 100)
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment