1.4k
You can create simple images by setting individual pixels on the 8×8 led matrix to different colors. In these examples we create some basic flags
Swedish flag
[codesyntax lang=”python”]
from sense_hat import SenseHat sense = SenseHat() r = (255, 0, 0) o = (255, 127, 0) y = (255, 255, 0) g = (0, 255, 0) b = (0, 0, 255) i = (75, 0, 130) v = (159, 0, 255) e = (0, 0, 0) image = [ b,b,y,y,b,b,b,b, b,b,y,y,b,b,b,b, b,b,y,y,b,b,b,b, y,y,y,y,y,y,y,y, y,y,y,y,y,y,y,y, b,b,y,y,b,b,b,b, b,b,y,y,b,b,b,b, b,b,y,y,b,b,b,b ] sense.set_pixels(image)
[/codesyntax]
French flag
[codesyntax lang=”python”]
from sense_hat import SenseHat sense = SenseHat() r = (255, 0, 0) o = (255, 127, 0) y = (255, 255, 0) g = (0, 255, 0) b = (0, 0, 255) i = (75, 0, 130) v = (159, 0, 255) e = (0, 0, 0) w = (255, 255, 255) image = [ b,b,b,w,w,r,r,r, b,b,b,w,w,r,r,r, b,b,b,w,w,r,r,r, b,b,b,w,w,r,r,r, b,b,b,w,w,r,r,r, b,b,b,w,w,r,r,r, b,b,b,w,w,r,r,r, b,b,b,w,w,r,r,r ] sense.set_pixels(image)
[/codesyntax]
Scottish flag
[codesyntax lang=”python”]
from sense_hat import SenseHat sense = SenseHat() r = (255, 0, 0) o = (255, 127, 0) y = (255, 255, 0) g = (0, 255, 0) b = (0, 0, 255) i = (75, 0, 130) v = (159, 0, 255) e = (0, 0, 0) w = (255, 255, 255) image = [ w,b,b,b,b,b,b,w, b,w,b,b,b,b,w,b, b,b,w,b,b,w,b,b, b,b,b,w,w,b,b,b, b,b,b,w,w,b,b,b, b,b,w,b,b,w,b,b, b,w,b,b,b,b,w,b, w,b,b,b,b,b,b,w ] sense.set_pixels(image)
[/codesyntax]