Skip to content

Instantly share code, notes, and snippets.

@mendesjorge
Last active April 17, 2016 01:17
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save mendesjorge/2be34353a62615630af75d0d32cfb629 to your computer and use it in GitHub Desktop.
Save mendesjorge/2be34353a62615630af75d0d32cfb629 to your computer and use it in GitHub Desktop.
function onStart( ) {
var x = 0;
var y = 0;
var forward = true;
while (true) {
if (microbit.isOn(x, y)) {
microbit.off(x, y);
microbit.off(4-x, y);
}else {
microbit.on(x, y);
microbit.on(4-x, y);
}
if (forward) {
x = x + 1;
forward = x <= 4;
}else {
x = x - 1;
forward = !( x >= 0 );
}
y = x;
wait(50);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment