Skip to content

Instantly share code, notes, and snippets.

@andreagrandi
Created February 7, 2016 21:51
Show Gist options
  • Save andreagrandi/99a09be27c9626b1119d to your computer and use it in GitHub Desktop.
Save andreagrandi/99a09be27c9626b1119d to your computer and use it in GitHub Desktop.
Display a Sun or a Moon on the BBC micro:bit display, depending on the value read from the light sensor
import microbit as m
SUN_IMAGE = m.Image(
"90909\n"
"09990\n"
"99999\n"
"09990\n"
"90909")
MOON_IMAGE = m.Image(
"99900\n"
"09990\n"
"00990\n"
"09990\n"
"99900")
while True:
light = m.pin0.read_analog()
if light > 512:
m.display.show(SUN_IMAGE)
else:
m.display.show(MOON_IMAGE)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment