Created
November 11, 2018 20:26
-
-
Save bketelsen/845f6fa382567303c2b788c4c444c3c6 to your computer and use it in GitHub Desktop.
microbit cylon
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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