-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathfunctions.py
85 lines (67 loc) · 2.15 KB
/
functions.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
import time
import pyfirmata
from fontstyle import apply
board = pyfirmata.Arduino('COM6') #setup
servo = board.get_pin('p:6:s')
red = board.get_pin('d:9:p') #red rgb
green = board.get_pin('d:10:p') #green rgb
blue = board.get_pin('d:11:p') #blue rgb
#text
def get_input():
get_input_string = apply("\nGuess a number between 1 and 100: ", 'bold/yellow')
input_usr = input(get_input_string)
return input_usr
def low_text():
low_string = apply("Guess is too low. Guess higher: ", 'blue')
low_input = input(low_string)
return low_input
def high_text():
high_string = apply("Guess is too high! Try a lower number: ", 'red')
high_input = input(high_string)
return high_input
def right_text():
right_string = apply("Thats RIGHT!!", 'green/bold/blink')
print(right_string)
time.sleep(0.3)
def invalid_input():
invalid_string = apply("Invalid input. Guess must be a number between 1 and 100: ", 'white/red_bg/bold/italic/')
invalid_getinput = input(invalid_string)
return invalid_getinput
def play_again():
play_again_string = apply("Type 'n' if you wish to stop playing (press 'enter' to play again): ", 'white/bold')
play_again_input = str(input(play_again_string))
return play_again_input
def alright():
alright_string = apply("Alright!", 'bold/darkcyan')
print(alright_string)
def thank_you():
thank_string = apply("Thanks for playing!", 'cyan/bold')
print(thank_string)
def led_stop():
red.write(0)
green.write(0)
blue.write(0)
def high_light(): #led - high (red light)
red.write(1)
green.write(0.25)
time.sleep(2.4)
red.write(0)
green.write(0)
def right_light(): #led - right (green light)
green.write(1)
time.sleep(5)
green.write(0)
def low_light():
blue.write(1)
time.sleep(2.4)
blue.write(0)
def ambient_light(): #constant color changing
red.write(1)
green.write(1)
blue.write(1)
board.pass_time(3)
def initialize(): #check if all components are working
servo.write(83)
ambient_light()
led_stop()
board.pass_time(1)