Skip to content

Instantly share code, notes, and snippets.

@KramKroc
Created October 14, 2017 08:10
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 KramKroc/3cce742340f276a4df4de58ac4ad3fef to your computer and use it in GitHub Desktop.
Save KramKroc/3cce742340f276a4df4de58ac4ad3fef to your computer and use it in GitHub Desktop.
Code for Mission Zero, displaying CoderDojo Banbridge logo
from sense_hat import SenseHat
from time import sleep
sense = SenseHat()
sense.set_rotation(270)
sense.show_message("Hello from Coderdojo Banbridge!", 0.05)
r = (255,0,0)
g = (0,255,0)
b = (0,0,255)
w = (255,255,255)
y = (255,255,0)
e = (0,0,0)
picture = [
w, w, w, r, r, w, w, w,
w, r, y, y, r, e, e, w,
w, r, y, y, r, r, e, w,
r, r, r, r, r, e, e, e,
r, r, r, r, e, e, e, e,
w, r, e, e, y, e, e, w,
w, r, r, e, y, e, e, w,
w, w, w, e, e, w, w, w
]
sense.set_pixels(picture)
sleep(2)
temp = sense.get_temperature()
temp = round( sense.get_temperature(), 2)
sense.show_message( "It is " + str(temp) + " degrees", 0.05)
hot = [
b, b, b, b, b, y, y, b,
b, b, b, b, y, y, y, y,
b, b, b, b, b, y, y, b,
b, b, b, b, b, b, b, b,
b, b, b, b, b, b, b, b,
b, b, b, b, b, b, b, b,
g, g, g, g, g, g, g, g,
g, g, g, g, g, g, g, g
]
cold = [
b, b, w, b, b, b, w, b,
b, b, b, b, b, w, b, b,
b, w, b, b, b, b, b, w,
b, b, b, b, w, b, b, b,
w, b, b, w, b, b, w, b,
b, b, b, b, b, b, b, b,
w, w, w, w, w, w, w, w,
w, w, w, w, w, w, w, w
]
if temp >= 20:
sense.set_pixels(hot)
else:
sense.set_pixels(cold)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment