Neigungssensor eingebaut
This commit is contained in:
parent
1c09f13528
commit
6ba17e9576
@ -6,13 +6,17 @@ from gpiozero import RotaryEncoder
|
|||||||
laser = Button(17) #Die Zahl entspricht dem Pin auf dem ARPI600 Board
|
laser = Button(17) #Die Zahl entspricht dem Pin auf dem ARPI600 Board
|
||||||
sound = Button(18, pull_up=True)
|
sound = Button(18, pull_up=True)
|
||||||
rotate = RotaryEncoder(21, 20)
|
rotate = RotaryEncoder(21, 20)
|
||||||
|
tilt = Button(23)
|
||||||
|
|
||||||
def score(x):
|
def score(x):
|
||||||
pass
|
pass
|
||||||
|
|
||||||
def command_tilt():
|
def command_tilt():
|
||||||
action = input()
|
print("waiting to get tilted...")
|
||||||
if action == "0":
|
result = tilt.wait_for_press(timeout=10)
|
||||||
|
print(f"Result: {result}")
|
||||||
|
if result:
|
||||||
|
time.sleep(0.3) # soll verhindern, dass die vorherige Runde die jetzige beeinflusst
|
||||||
return 1
|
return 1
|
||||||
else:
|
else:
|
||||||
return -1
|
return -1
|
||||||
@ -63,7 +67,7 @@ def main():
|
|||||||
result = 0
|
result = 0
|
||||||
sound.when_held = sound_was_held
|
sound.when_held = sound_was_held
|
||||||
print("Let's play a Round of 'Raspberry says'!")
|
print("Let's play a Round of 'Raspberry says'!")
|
||||||
list_command_choices = [command_spin_clockwise, command_spin_counter_clockwise] #command_spin, command_tilt, command_blind_ command_scream
|
list_command_choices =[command_tilt] # [command_spin_clockwise, command_spin_counter_clockwise] #command_spin, command_tilt, command_blind_ command_scream
|
||||||
while result != -1:
|
while result != -1:
|
||||||
score += result # war zuerst zwei Zeilen weiter unten, hat dann aber nach einer falschen Runde den Score erhöht
|
score += result # war zuerst zwei Zeilen weiter unten, hat dann aber nach einer falschen Runde den Score erhöht
|
||||||
time.sleep(0.5)
|
time.sleep(0.5)
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user