Code: Select all
from sense_hat import SenseHat
from time import sleep
sense = SenseHat()
sense.set_rotation(180)
red = (255, 0, 0)
def get_color(color):
keep_looping = True
no_of_try=1
while keep_looping:
#color_str=input("Enter the value of the" + color + \ "color for message (0 to 255):")
while no_of_try < 4:
color_str = input("Enter the value of the " + color + " color for message (0 to 255):")
no_of_try += 1
if int(color_str) in range(0, 256):
print(color_str)
return color_str
else:
print("Input only 0 to 255.")
print('number of tries exceeded')
return 0
#---------------------------------------------------------
r_int = get_color("red")
g_int = get_color("green")
b_int = get_color("blue")
msg_color = (r_int, g_int, b_int)
sense.show_message("I got it!", text_colour = msg_color, scroll_speed = 0.05)