Created
February 7, 2016 21:51
-
-
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
This file contains hidden or 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
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