# Unicornhat Binary/Tix clock

I got bored of doing my DIY chores so decided to make myself a clock. It doesn’t have seconds as I wanted nice big 2x2 pixels to represent the numbers.

I am very new to python so this isn’t going to be the best solution to the problem, I got a little stuck so turned to Sandy and Phil on twitter but in the end got it working without their help.

my to do list is to make the squares random colours, improve/shorten the code etc.

``````# import stuff

import time
import unicornhat

# settings

unicornhat.brightness(0.3)

# store the time in these

digit_one = 99
digit_two = 99
digit_three = 99
digit_four = 99

# map of digits to paint on the unicornhat

def digit_1_0():
unicornhat.set_pixel(6, 0, 0, 0, 0)
unicornhat.set_pixel(6, 1, 0, 0, 0)
unicornhat.set_pixel(6, 2, 0, 0, 0)
unicornhat.set_pixel(6, 3, 0, 0, 0)
unicornhat.set_pixel(6, 4, 0, 0, 0)
unicornhat.set_pixel(6, 5, 0, 0, 0)
unicornhat.set_pixel(6, 6, 0, 0, 0)
unicornhat.set_pixel(6, 7, 0, 0, 0)
unicornhat.set_pixel(7, 0, 0, 0, 0)
unicornhat.set_pixel(7, 1, 0, 0, 0)
unicornhat.set_pixel(7, 2, 0, 0, 0)
unicornhat.set_pixel(7, 3, 0, 0, 0)
unicornhat.set_pixel(7, 4, 0, 0, 0)
unicornhat.set_pixel(7, 5, 0, 0, 0)
unicornhat.set_pixel(7, 6, 0, 0, 0)
unicornhat.set_pixel(7, 7, 0, 0, 0)

def digit_1_1():
unicornhat.set_pixel(6, 0, 255, 0, 0)
unicornhat.set_pixel(6, 1, 255, 0, 0)
unicornhat.set_pixel(6, 2, 0, 0, 0)
unicornhat.set_pixel(6, 3, 0, 0, 0)
unicornhat.set_pixel(6, 4, 0, 0, 0)
unicornhat.set_pixel(6, 5, 0, 0, 0)
unicornhat.set_pixel(6, 6, 0, 0, 0)
unicornhat.set_pixel(6, 7, 0, 0, 0)
unicornhat.set_pixel(7, 0, 255, 0, 0)
unicornhat.set_pixel(7, 1, 255, 0, 0)
unicornhat.set_pixel(7, 2, 0, 0, 0)
unicornhat.set_pixel(7, 3, 0, 0, 0)
unicornhat.set_pixel(7, 4, 0, 0, 0)
unicornhat.set_pixel(7, 5, 0, 0, 0)
unicornhat.set_pixel(7, 6, 0, 0, 0)
unicornhat.set_pixel(7, 7, 0, 0, 0)

def digit_1_2():
unicornhat.set_pixel(6, 0, 0, 0, 0)
unicornhat.set_pixel(6, 1, 0, 0, 0)
unicornhat.set_pixel(6, 2, 255, 0, 0)
unicornhat.set_pixel(6, 3, 255, 0, 0)
unicornhat.set_pixel(6, 4, 0, 0, 0)
unicornhat.set_pixel(6, 5, 0, 0, 0)
unicornhat.set_pixel(6, 6, 0, 0, 0)
unicornhat.set_pixel(6, 7, 0, 0, 0)
unicornhat.set_pixel(7, 0, 0, 0, 0)
unicornhat.set_pixel(7, 1, 0, 0, 0)
unicornhat.set_pixel(7, 2, 255, 0, 0)
unicornhat.set_pixel(7, 3, 255, 0, 0)
unicornhat.set_pixel(7, 4, 0, 0, 0)
unicornhat.set_pixel(7, 5, 0, 0, 0)
unicornhat.set_pixel(7, 6, 0, 0, 0)
unicornhat.set_pixel(7, 7, 0, 0, 0)

def digit_2_0():
unicornhat.set_pixel(4, 0, 0, 0, 0)
unicornhat.set_pixel(4, 1, 0, 0, 0)
unicornhat.set_pixel(4, 2, 0, 0, 0)
unicornhat.set_pixel(4, 3, 0, 0, 0)
unicornhat.set_pixel(4, 4, 0, 0, 0)
unicornhat.set_pixel(4, 5, 0, 0, 0)
unicornhat.set_pixel(4, 6, 0, 0, 0)
unicornhat.set_pixel(4, 7, 0, 0, 0)
unicornhat.set_pixel(5, 0, 0, 0, 0)
unicornhat.set_pixel(5, 1, 0, 0, 0)
unicornhat.set_pixel(5, 2, 0, 0, 0)
unicornhat.set_pixel(5, 3, 0, 0, 0)
unicornhat.set_pixel(5, 4, 0, 0, 0)
unicornhat.set_pixel(5, 5, 0, 0, 0)
unicornhat.set_pixel(5, 6, 0, 0, 0)
unicornhat.set_pixel(5, 7, 0, 0, 0)

def digit_2_1():
unicornhat.set_pixel(4, 0, 255, 0, 0)
unicornhat.set_pixel(4, 1, 255, 0, 0)
unicornhat.set_pixel(4, 2, 0, 0, 0)
unicornhat.set_pixel(4, 3, 0, 0, 0)
unicornhat.set_pixel(4, 4, 0, 0, 0)
unicornhat.set_pixel(4, 5, 0, 0, 0)
unicornhat.set_pixel(4, 6, 0, 0, 0)
unicornhat.set_pixel(4, 7, 0, 0, 0)
unicornhat.set_pixel(5, 0, 255, 0, 0)
unicornhat.set_pixel(5, 1, 255, 0, 0)
unicornhat.set_pixel(5, 2, 0, 0, 0)
unicornhat.set_pixel(5, 3, 0, 0, 0)
unicornhat.set_pixel(5, 4, 0, 0, 0)
unicornhat.set_pixel(5, 5, 0, 0, 0)
unicornhat.set_pixel(5, 6, 0, 0, 0)
unicornhat.set_pixel(5, 7, 0, 0, 0)

def digit_2_2():
unicornhat.set_pixel(4, 0, 0, 0, 0)
unicornhat.set_pixel(4, 1, 0, 0, 0)
unicornhat.set_pixel(4, 2, 255, 0, 0)
unicornhat.set_pixel(4, 3, 255, 0, 0)
unicornhat.set_pixel(4, 4, 0, 0, 0)
unicornhat.set_pixel(4, 5, 0, 0, 0)
unicornhat.set_pixel(4, 6, 0, 0, 0)
unicornhat.set_pixel(4, 7, 0, 0, 0)
unicornhat.set_pixel(5, 0, 0, 0, 0)
unicornhat.set_pixel(5, 1, 0, 0, 0)
unicornhat.set_pixel(5, 2, 255, 0, 0)
unicornhat.set_pixel(5, 3, 255, 0, 0)
unicornhat.set_pixel(5, 4, 0, 0, 0)
unicornhat.set_pixel(5, 5, 0, 0, 0)
unicornhat.set_pixel(5, 6, 0, 0, 0)
unicornhat.set_pixel(5, 7, 0, 0, 0)

def digit_2_3():
unicornhat.set_pixel(4, 0, 255, 0, 0)
unicornhat.set_pixel(4, 1, 255, 0, 0)
unicornhat.set_pixel(4, 2, 255, 0, 0)
unicornhat.set_pixel(4, 3, 255, 0, 0)
unicornhat.set_pixel(4, 4, 0, 0, 0)
unicornhat.set_pixel(4, 5, 0, 0, 0)
unicornhat.set_pixel(4, 6, 0, 0, 0)
unicornhat.set_pixel(4, 7, 0, 0, 0)
unicornhat.set_pixel(5, 0, 255, 0, 0)
unicornhat.set_pixel(5, 1, 255, 0, 0)
unicornhat.set_pixel(5, 2, 255, 0, 0)
unicornhat.set_pixel(5, 3, 255, 0, 0)
unicornhat.set_pixel(5, 4, 0, 0, 0)
unicornhat.set_pixel(5, 5, 0, 0, 0)
unicornhat.set_pixel(5, 6, 0, 0, 0)
unicornhat.set_pixel(5, 7, 0, 0, 0)

def digit_2_4():
unicornhat.set_pixel(4, 0, 0, 0, 0)
unicornhat.set_pixel(4, 1, 0, 0, 0)
unicornhat.set_pixel(4, 2, 0, 0, 0)
unicornhat.set_pixel(4, 3, 0, 0, 0)
unicornhat.set_pixel(4, 4, 255, 0, 0)
unicornhat.set_pixel(4, 5, 255, 0, 0)
unicornhat.set_pixel(4, 6, 0, 0, 0)
unicornhat.set_pixel(4, 7, 0, 0, 0)
unicornhat.set_pixel(5, 0, 0, 0, 0)
unicornhat.set_pixel(5, 1, 0, 0, 0)
unicornhat.set_pixel(5, 2, 0, 0, 0)
unicornhat.set_pixel(5, 3, 0, 0, 0)
unicornhat.set_pixel(5, 4, 255, 0, 0)
unicornhat.set_pixel(5, 5, 255, 0, 0)
unicornhat.set_pixel(5, 6, 0, 0, 0)
unicornhat.set_pixel(5, 7, 0, 0, 0)

def digit_2_5():
unicornhat.set_pixel(4, 0, 255, 0, 0)
unicornhat.set_pixel(4, 1, 255, 0, 0)
unicornhat.set_pixel(4, 2, 0, 0, 0)
unicornhat.set_pixel(4, 3, 0, 0, 0)
unicornhat.set_pixel(4, 4, 255, 0, 0)
unicornhat.set_pixel(4, 5, 255, 0, 0)
unicornhat.set_pixel(4, 6, 0, 0, 0)
unicornhat.set_pixel(4, 7, 0, 0, 0)
unicornhat.set_pixel(5, 0, 255, 0, 0)
unicornhat.set_pixel(5, 1, 255, 0, 0)
unicornhat.set_pixel(5, 2, 0, 0, 0)
unicornhat.set_pixel(5, 3, 0, 0, 0)
unicornhat.set_pixel(5, 4, 255, 0, 0)
unicornhat.set_pixel(5, 5, 255, 0, 0)
unicornhat.set_pixel(5, 6, 0, 0, 0)
unicornhat.set_pixel(5, 7, 0, 0, 0)

def digit_2_6():
unicornhat.set_pixel(4, 0, 0, 0, 0)
unicornhat.set_pixel(4, 1, 0, 0, 0)
unicornhat.set_pixel(4, 2, 255, 0, 0)
unicornhat.set_pixel(4, 3, 255, 0, 0)
unicornhat.set_pixel(4, 4, 255, 0, 0)
unicornhat.set_pixel(4, 5, 255, 0, 0)
unicornhat.set_pixel(4, 6, 0, 0, 0)
unicornhat.set_pixel(4, 7, 0, 0, 0)
unicornhat.set_pixel(5, 0, 0, 0, 0)
unicornhat.set_pixel(5, 1, 0, 0, 0)
unicornhat.set_pixel(5, 2, 255, 0, 0)
unicornhat.set_pixel(5, 3, 255, 0, 0)
unicornhat.set_pixel(5, 4, 255, 0, 0)
unicornhat.set_pixel(5, 5, 255, 0, 0)
unicornhat.set_pixel(5, 6, 0, 0, 0)
unicornhat.set_pixel(5, 7, 0, 0, 0)

def digit_2_7():
unicornhat.set_pixel(4, 0, 255, 0, 0)
unicornhat.set_pixel(4, 1, 255, 0, 0)
unicornhat.set_pixel(4, 2, 255, 0, 0)
unicornhat.set_pixel(4, 3, 255, 0, 0)
unicornhat.set_pixel(4, 4, 255, 0, 0)
unicornhat.set_pixel(4, 5, 255, 0, 0)
unicornhat.set_pixel(4, 6, 0, 0, 0)
unicornhat.set_pixel(4, 7, 0, 0, 0)
unicornhat.set_pixel(5, 0, 255, 0, 0)
unicornhat.set_pixel(5, 1, 255, 0, 0)
unicornhat.set_pixel(5, 2, 255, 0, 0)
unicornhat.set_pixel(5, 3, 255, 0, 0)
unicornhat.set_pixel(5, 4, 255, 0, 0)
unicornhat.set_pixel(5, 5, 255, 0, 0)
unicornhat.set_pixel(5, 6, 0, 0, 0)
unicornhat.set_pixel(5, 7, 0, 0, 0)

def digit_2_8():
unicornhat.set_pixel(4, 0, 0, 0, 0)
unicornhat.set_pixel(4, 1, 0, 0, 0)
unicornhat.set_pixel(4, 2, 0, 0, 0)
unicornhat.set_pixel(4, 3, 0, 0, 0)
unicornhat.set_pixel(4, 4, 0, 0, 0)
unicornhat.set_pixel(4, 5, 0, 0, 0)
unicornhat.set_pixel(4, 6, 255, 0, 0)
unicornhat.set_pixel(4, 7, 255, 0, 0)
unicornhat.set_pixel(5, 0, 0, 0, 0)
unicornhat.set_pixel(5, 1, 0, 0, 0)
unicornhat.set_pixel(5, 2, 0, 0, 0)
unicornhat.set_pixel(5, 3, 0, 0, 0)
unicornhat.set_pixel(5, 4, 0, 0, 0)
unicornhat.set_pixel(5, 5, 0, 0, 0)
unicornhat.set_pixel(5, 6, 255, 0, 0)
unicornhat.set_pixel(5, 7, 255, 0, 0)

def digit_2_9():
unicornhat.set_pixel(4, 0, 255, 0, 0)
unicornhat.set_pixel(4, 1, 255, 0, 0)
unicornhat.set_pixel(4, 2, 0, 0, 0)
unicornhat.set_pixel(4, 3, 0, 0, 0)
unicornhat.set_pixel(4, 4, 0, 0, 0)
unicornhat.set_pixel(4, 5, 0, 0, 0)
unicornhat.set_pixel(4, 6, 255, 0, 0)
unicornhat.set_pixel(4, 7, 255, 0, 0)
unicornhat.set_pixel(5, 0, 255, 0, 0)
unicornhat.set_pixel(5, 1, 255, 0, 0)
unicornhat.set_pixel(5, 2, 0, 0, 0)
unicornhat.set_pixel(5, 3, 0, 0, 0)
unicornhat.set_pixel(5, 4, 0, 0, 0)
unicornhat.set_pixel(5, 5, 0, 0, 0)
unicornhat.set_pixel(5, 6, 255, 0, 0)
unicornhat.set_pixel(5, 7, 255, 0, 0)

def digit_3_0():
unicornhat.set_pixel(2, 0, 0, 0, 0)
unicornhat.set_pixel(2, 1, 0, 0, 0)
unicornhat.set_pixel(2, 2, 0, 0, 0)
unicornhat.set_pixel(2, 3, 0, 0, 0)
unicornhat.set_pixel(2, 4, 0, 0, 0)
unicornhat.set_pixel(2, 5, 0, 0, 0)
unicornhat.set_pixel(2, 6, 0, 0, 0)
unicornhat.set_pixel(2, 7, 0, 0, 0)
unicornhat.set_pixel(3, 0, 0, 0, 0)
unicornhat.set_pixel(3, 1, 0, 0, 0)
unicornhat.set_pixel(3, 2, 0, 0, 0)
unicornhat.set_pixel(3, 3, 0, 0, 0)
unicornhat.set_pixel(3, 4, 0, 0, 0)
unicornhat.set_pixel(3, 5, 0, 0, 0)
unicornhat.set_pixel(3, 6, 0, 0, 0)
unicornhat.set_pixel(3, 7, 0, 0, 0)

def digit_3_1():
unicornhat.set_pixel(2, 0, 255, 0, 0)
unicornhat.set_pixel(2, 1, 255, 0, 0)
unicornhat.set_pixel(2, 2, 0, 0, 0)
unicornhat.set_pixel(2, 3, 0, 0, 0)
unicornhat.set_pixel(2, 4, 0, 0, 0)
unicornhat.set_pixel(2, 5, 0, 0, 0)
unicornhat.set_pixel(2, 6, 0, 0, 0)
unicornhat.set_pixel(2, 7, 0, 0, 0)
unicornhat.set_pixel(3, 0, 255, 0, 0)
unicornhat.set_pixel(3, 1, 255, 0, 0)
unicornhat.set_pixel(3, 2, 0, 0, 0)
unicornhat.set_pixel(3, 3, 0, 0, 0)
unicornhat.set_pixel(3, 4, 0, 0, 0)
unicornhat.set_pixel(3, 5, 0, 0, 0)
unicornhat.set_pixel(3, 6, 0, 0, 0)
unicornhat.set_pixel(3, 7, 0, 0, 0)

def digit_3_2():
unicornhat.set_pixel(2, 0, 0, 0, 0)
unicornhat.set_pixel(2, 1, 0, 0, 0)
unicornhat.set_pixel(2, 2, 255, 0, 0)
unicornhat.set_pixel(2, 3, 255, 0, 0)
unicornhat.set_pixel(2, 4, 0, 0, 0)
unicornhat.set_pixel(2, 5, 0, 0, 0)
unicornhat.set_pixel(2, 6, 0, 0, 0)
unicornhat.set_pixel(2, 7, 0, 0, 0)
unicornhat.set_pixel(3, 0, 0, 0, 0)
unicornhat.set_pixel(3, 1, 0, 0, 0)
unicornhat.set_pixel(3, 2, 255, 0, 0)
unicornhat.set_pixel(3, 3, 255, 0, 0)
unicornhat.set_pixel(3, 4, 0, 0, 0)
unicornhat.set_pixel(3, 5, 0, 0, 0)
unicornhat.set_pixel(3, 6, 0, 0, 0)
unicornhat.set_pixel(3, 7, 0, 0, 0)

def digit_3_3():
unicornhat.set_pixel(2, 0, 255, 0, 0)
unicornhat.set_pixel(2, 1, 255, 0, 0)
unicornhat.set_pixel(2, 2, 255, 0, 0)
unicornhat.set_pixel(2, 3, 255, 0, 0)
unicornhat.set_pixel(2, 4, 0, 0, 0)
unicornhat.set_pixel(2, 5, 0, 0, 0)
unicornhat.set_pixel(2, 6, 0, 0, 0)
unicornhat.set_pixel(2, 7, 0, 0, 0)
unicornhat.set_pixel(3, 0, 255, 0, 0)
unicornhat.set_pixel(3, 1, 255, 0, 0)
unicornhat.set_pixel(3, 2, 255, 0, 0)
unicornhat.set_pixel(3, 3, 255, 0, 0)
unicornhat.set_pixel(3, 4, 0, 0, 0)
unicornhat.set_pixel(3, 5, 0, 0, 0)
unicornhat.set_pixel(3, 6, 0, 0, 0)
unicornhat.set_pixel(3, 7, 0, 0, 0)

def digit_3_4():
unicornhat.set_pixel(2, 0, 0, 0, 0)
unicornhat.set_pixel(2, 1, 0, 0, 0)
unicornhat.set_pixel(2, 2, 0, 0, 0)
unicornhat.set_pixel(2, 3, 0, 0, 0)
unicornhat.set_pixel(2, 4, 255, 0, 0)
unicornhat.set_pixel(2, 5, 255, 0, 0)
unicornhat.set_pixel(2, 6, 0, 0, 0)
unicornhat.set_pixel(2, 7, 0, 0, 0)
unicornhat.set_pixel(3, 0, 0, 0, 0)
unicornhat.set_pixel(3, 1, 0, 0, 0)
unicornhat.set_pixel(3, 2, 0, 0, 0)
unicornhat.set_pixel(3, 3, 0, 0, 0)
unicornhat.set_pixel(3, 4, 255, 0, 0)
unicornhat.set_pixel(3, 5, 255, 0, 0)
unicornhat.set_pixel(3, 6, 0, 0, 0)
unicornhat.set_pixel(3, 7, 0, 0, 0)

def digit_3_5():
unicornhat.set_pixel(2, 0, 255, 0, 0)
unicornhat.set_pixel(2, 1, 255, 0, 0)
unicornhat.set_pixel(2, 2, 0, 0, 0)
unicornhat.set_pixel(2, 3, 0, 0, 0)
unicornhat.set_pixel(2, 4, 255, 0, 0)
unicornhat.set_pixel(2, 5, 255, 0, 0)
unicornhat.set_pixel(2, 6, 0, 0, 0)
unicornhat.set_pixel(2, 7, 0, 0, 0)
unicornhat.set_pixel(3, 0, 255, 0, 0)
unicornhat.set_pixel(3, 1, 255, 0, 0)
unicornhat.set_pixel(3, 2, 0, 0, 0)
unicornhat.set_pixel(3, 3, 0, 0, 0)
unicornhat.set_pixel(3, 4, 255, 0, 0)
unicornhat.set_pixel(3, 5, 255, 0, 0)
unicornhat.set_pixel(3, 6, 0, 0, 0)
unicornhat.set_pixel(3, 7, 0, 0, 0)

def digit_4_0():
unicornhat.set_pixel(0, 0, 0, 0, 0)
unicornhat.set_pixel(0, 1, 0, 0, 0)
unicornhat.set_pixel(0, 2, 0, 0, 0)
unicornhat.set_pixel(0, 3, 0, 0, 0)
unicornhat.set_pixel(0, 4, 0, 0, 0)
unicornhat.set_pixel(0, 5, 0, 0, 0)
unicornhat.set_pixel(0, 6, 0, 0, 0)
unicornhat.set_pixel(0, 7, 0, 0, 0)
unicornhat.set_pixel(1, 0, 0, 0, 0)
unicornhat.set_pixel(1, 1, 0, 0, 0)
unicornhat.set_pixel(1, 2, 0, 0, 0)
unicornhat.set_pixel(1, 3, 0, 0, 0)
unicornhat.set_pixel(1, 4, 0, 0, 0)
unicornhat.set_pixel(1, 5, 0, 0, 0)
unicornhat.set_pixel(1, 6, 0, 0, 0)
unicornhat.set_pixel(1, 7, 0, 0, 0)

def digit_4_1():
unicornhat.set_pixel(0, 0, 255, 0, 0)
unicornhat.set_pixel(0, 1, 255, 0, 0)
unicornhat.set_pixel(0, 2, 0, 0, 0)
unicornhat.set_pixel(0, 3, 0, 0, 0)
unicornhat.set_pixel(0, 4, 0, 0, 0)
unicornhat.set_pixel(0, 5, 0, 0, 0)
unicornhat.set_pixel(0, 6, 0, 0, 0)
unicornhat.set_pixel(0, 7, 0, 0, 0)
unicornhat.set_pixel(1, 0, 255, 0, 0)
unicornhat.set_pixel(1, 1, 255, 0, 0)
unicornhat.set_pixel(1, 2, 0, 0, 0)
unicornhat.set_pixel(1, 3, 0, 0, 0)
unicornhat.set_pixel(1, 4, 0, 0, 0)
unicornhat.set_pixel(1, 5, 0, 0, 0)
unicornhat.set_pixel(1, 6, 0, 0, 0)
unicornhat.set_pixel(1, 7, 0, 0, 0)

def digit_4_2():
unicornhat.set_pixel(0, 0, 0, 0, 0)
unicornhat.set_pixel(0, 1, 0, 0, 0)
unicornhat.set_pixel(0, 2, 255, 0, 0)
unicornhat.set_pixel(0, 3, 255, 0, 0)
unicornhat.set_pixel(0, 4, 0, 0, 0)
unicornhat.set_pixel(0, 5, 0, 0, 0)
unicornhat.set_pixel(0, 6, 0, 0, 0)
unicornhat.set_pixel(0, 7, 0, 0, 0)
unicornhat.set_pixel(1, 0, 0, 0, 0)
unicornhat.set_pixel(1, 1, 0, 0, 0)
unicornhat.set_pixel(1, 2, 255, 0, 0)
unicornhat.set_pixel(1, 3, 255, 0, 0)
unicornhat.set_pixel(1, 4, 0, 0, 0)
unicornhat.set_pixel(1, 5, 0, 0, 0)
unicornhat.set_pixel(1, 6, 0, 0, 0)
unicornhat.set_pixel(1, 7, 0, 0, 0)

def digit_4_3():
unicornhat.set_pixel(0, 0, 255, 0, 0)
unicornhat.set_pixel(0, 1, 255, 0, 0)
unicornhat.set_pixel(0, 2, 255, 0, 0)
unicornhat.set_pixel(0, 3, 255, 0, 0)
unicornhat.set_pixel(0, 4, 0, 0, 0)
unicornhat.set_pixel(0, 5, 0, 0, 0)
unicornhat.set_pixel(0, 6, 0, 0, 0)
unicornhat.set_pixel(0, 7, 0, 0, 0)
unicornhat.set_pixel(1, 0, 255, 0, 0)
unicornhat.set_pixel(1, 1, 255, 0, 0)
unicornhat.set_pixel(1, 2, 255, 0, 0)
unicornhat.set_pixel(1, 3, 255, 0, 0)
unicornhat.set_pixel(1, 4, 0, 0, 0)
unicornhat.set_pixel(1, 5, 0, 0, 0)
unicornhat.set_pixel(1, 6, 0, 0, 0)
unicornhat.set_pixel(1, 7, 0, 0, 0)

def digit_4_4():
unicornhat.set_pixel(0, 0, 0, 0, 0)
unicornhat.set_pixel(0, 1, 0, 0, 0)
unicornhat.set_pixel(0, 2, 0, 0, 0)
unicornhat.set_pixel(0, 3, 0, 0, 0)
unicornhat.set_pixel(0, 4, 255, 0, 0)
unicornhat.set_pixel(0, 5, 255, 0, 0)
unicornhat.set_pixel(0, 6, 0, 0, 0)
unicornhat.set_pixel(0, 7, 0, 0, 0)
unicornhat.set_pixel(1, 0, 0, 0, 0)
unicornhat.set_pixel(1, 1, 0, 0, 0)
unicornhat.set_pixel(1, 2, 0, 0, 0)
unicornhat.set_pixel(1, 3, 0, 0, 0)
unicornhat.set_pixel(1, 4, 255, 0, 0)
unicornhat.set_pixel(1, 5, 255, 0, 0)
unicornhat.set_pixel(1, 6, 0, 0, 0)
unicornhat.set_pixel(1, 7, 0, 0, 0)

def digit_4_5():
unicornhat.set_pixel(0, 0, 255, 0, 0)
unicornhat.set_pixel(0, 1, 255, 0, 0)
unicornhat.set_pixel(0, 2, 0, 0, 0)
unicornhat.set_pixel(0, 3, 0, 0, 0)
unicornhat.set_pixel(0, 4, 255, 0, 0)
unicornhat.set_pixel(0, 5, 255, 0, 0)
unicornhat.set_pixel(0, 6, 0, 0, 0)
unicornhat.set_pixel(0, 7, 0, 0, 0)
unicornhat.set_pixel(1, 0, 255, 0, 0)
unicornhat.set_pixel(1, 1, 255, 0, 0)
unicornhat.set_pixel(1, 2, 0, 0, 0)
unicornhat.set_pixel(1, 3, 0, 0, 0)
unicornhat.set_pixel(1, 4, 255, 0, 0)
unicornhat.set_pixel(1, 5, 255, 0, 0)
unicornhat.set_pixel(1, 6, 0, 0, 0)
unicornhat.set_pixel(1, 7, 0, 0, 0)

def digit_4_6():
unicornhat.set_pixel(0, 0, 0, 0, 0)
unicornhat.set_pixel(0, 1, 0, 0, 0)
unicornhat.set_pixel(0, 2, 255, 0, 0)
unicornhat.set_pixel(0, 3, 255, 0, 0)
unicornhat.set_pixel(0, 4, 255, 0, 0)
unicornhat.set_pixel(0, 5, 255, 0, 0)
unicornhat.set_pixel(0, 6, 0, 0, 0)
unicornhat.set_pixel(0, 7, 0, 0, 0)
unicornhat.set_pixel(1, 0, 0, 0, 0)
unicornhat.set_pixel(1, 1, 0, 0, 0)
unicornhat.set_pixel(1, 2, 255, 0, 0)
unicornhat.set_pixel(1, 3, 255, 0, 0)
unicornhat.set_pixel(1, 4, 255, 0, 0)
unicornhat.set_pixel(1, 5, 255, 0, 0)
unicornhat.set_pixel(1, 6, 0, 0, 0)
unicornhat.set_pixel(1, 7, 0, 0, 0)

def digit_4_7():
unicornhat.set_pixel(0, 0, 255, 0, 0)
unicornhat.set_pixel(0, 1, 255, 0, 0)
unicornhat.set_pixel(0, 2, 255, 0, 0)
unicornhat.set_pixel(0, 3, 255, 0, 0)
unicornhat.set_pixel(0, 4, 255, 0, 0)
unicornhat.set_pixel(0, 5, 255, 0, 0)
unicornhat.set_pixel(0, 6, 0, 0, 0)
unicornhat.set_pixel(0, 7, 0, 0, 0)
unicornhat.set_pixel(1, 0, 255, 0, 0)
unicornhat.set_pixel(1, 1, 255, 0, 0)
unicornhat.set_pixel(1, 2, 255, 0, 0)
unicornhat.set_pixel(1, 3, 255, 0, 0)
unicornhat.set_pixel(1, 4, 255, 0, 0)
unicornhat.set_pixel(1, 5, 255, 0, 0)
unicornhat.set_pixel(1, 6, 0, 0, 0)
unicornhat.set_pixel(1, 7, 0, 0, 0)

def digit_4_8():
unicornhat.set_pixel(0, 0, 0, 0, 0)
unicornhat.set_pixel(0, 1, 0, 0, 0)
unicornhat.set_pixel(0, 2, 0, 0, 0)
unicornhat.set_pixel(0, 3, 0, 0, 0)
unicornhat.set_pixel(0, 4, 0, 0, 0)
unicornhat.set_pixel(0, 5, 0, 0, 0)
unicornhat.set_pixel(0, 6, 255, 0, 0)
unicornhat.set_pixel(0, 7, 255, 0, 0)
unicornhat.set_pixel(1, 0, 0, 0, 0)
unicornhat.set_pixel(1, 1, 0, 0, 0)
unicornhat.set_pixel(1, 2, 0, 0, 0)
unicornhat.set_pixel(1, 3, 0, 0, 0)
unicornhat.set_pixel(1, 4, 0, 0, 0)
unicornhat.set_pixel(1, 5, 0, 0, 0)
unicornhat.set_pixel(1, 6, 255, 0, 0)
unicornhat.set_pixel(1, 7, 255, 0, 0)

def digit_4_9():
unicornhat.set_pixel(0, 0, 255, 0, 0)
unicornhat.set_pixel(0, 1, 255, 0, 0)
unicornhat.set_pixel(0, 2, 0, 0, 0)
unicornhat.set_pixel(0, 3, 0, 0, 0)
unicornhat.set_pixel(0, 4, 0, 0, 0)
unicornhat.set_pixel(0, 5, 0, 0, 0)
unicornhat.set_pixel(0, 6, 255, 0, 0)
unicornhat.set_pixel(0, 7, 255, 0, 0)
unicornhat.set_pixel(1, 0, 255, 0, 0)
unicornhat.set_pixel(1, 1, 255, 0, 0)
unicornhat.set_pixel(1, 2, 0, 0, 0)
unicornhat.set_pixel(1, 3, 0, 0, 0)
unicornhat.set_pixel(1, 4, 0, 0, 0)
unicornhat.set_pixel(1, 5, 0, 0, 0)
unicornhat.set_pixel(1, 6, 255, 0, 0)
unicornhat.set_pixel(1, 7, 255, 0, 0)

# here comes the loop

print "Hello"

time.sleep(1)

print digit_one
print digit_two
print digit_three
print digit_four

time.sleep(1)

digit_one = time.strftime("%H")[0]
digit_two = time.strftime("%H")[1]
digit_three = time.strftime("%M")[0]
digit_four = time.strftime("%M")[1]

time.sleep(1)

while True:

if digit_one == "0":
print digit_one
digit_one = 99
digit_1_0()

if digit_one == "1":
print digit_one
digit_one = 99
digit_1_1()

if digit_one == "2":
print digit_one
digit_one = 99
digit_1_2()

if digit_two == "0":
print digit_two
digit_two = 99
digit_2_0()

if digit_two == "1":
print digit_two
digit_two = 99
digit_2_1()

if digit_two == "2":
print digit_two
digit_two = 99
digit_2_2()

if digit_two == "3":
print digit_two
digit_two = 99
digit_2_3()

if digit_two == "4":
print digit_two
digit_two = 99
digit_2_4()

if digit_two == "5":
print digit_two
digit_two = 99
digit_2_5()

if digit_two == "6":
print digit_two
digit_two = 99
digit_2_6()

if digit_two == "7":
print digit_two
digit_two = 99
digit_2_7()

if digit_two == "8":
print digit_two
digit_two = 99
digit_2_8()

if digit_two == "9":
print digit_two
digit_two = 99
digit_2_9()

if digit_three == "0":
print digit_three
digit_three = 99
digit_3_0()

if digit_three == "1":
print digit_three
digit_three = 99
digit_3_1()

if digit_three == "2":
print digit_three
digit_three = 99
digit_3_2()

if digit_three == "3":
print digit_three
digit_three = 99
digit_3_3()

if digit_three == "4":
print digit_three
digit_three = 99
digit_3_4()

if digit_three == "5":
print digit_three
digit_three = 99
digit_3_5()

if digit_four == "0":
print digit_four
digit_four = 99
digit_4_0()

if digit_four == "1":
print digit_four
digit_four = 99
digit_4_1()

if digit_four == "2":
print digit_four
digit_four = 99
digit_4_2()

if digit_four == "3":
print digit_four
digit_four = 99
digit_4_3()

if digit_four == "4":
print digit_four
digit_four = 99
digit_4_4()

if digit_four == "5":
print digit_four
digit_four = 99
digit_4_5()

if digit_four == "6":
print digit_four
digit_four = 99
digit_4_6()

if digit_four == "7":
print digit_four
digit_four = 99
digit_4_7()

if digit_four == "8":
print digit_four
digit_four = 99
digit_4_8()

if digit_four == "9":
print digit_four
digit_four = 99
digit_4_9()

else:
unicornhat.show()
digit_one = time.strftime("%H")[0]
digit_two = time.strftime("%H")[1]
digit_three = time.strftime("%M")[0]
digit_four = time.strftime("%M")[1]
print digit_one
print digit_two
print digit_three
print digit_four
time.sleep(1)``````

Good stuff, although employing a list would really help condense your code. As a basic, drop-in example ( which, err, may or may not work :D ):

``````digit_one_patterns = [digit_1_0, digit_1_1, digit_1_2]

if int(digit_one) in digit_one_patterns.keys():
digit_one_patterns[int(digit_one)]
digit_one = 99
``````

thank you Phil, I will make a version two at some point