From 6ba17e957686e9e510fb9c3da589260ab3185528 Mon Sep 17 00:00:00 2001 From: Franziska Gerold Date: Fri, 19 Dec 2025 01:38:45 +1100 Subject: [PATCH] Neigungssensor eingebaut --- Bop_it_sensors.py | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/Bop_it_sensors.py b/Bop_it_sensors.py index 6ecc18c..4b829a2 100644 --- a/Bop_it_sensors.py +++ b/Bop_it_sensors.py @@ -6,13 +6,17 @@ from gpiozero import RotaryEncoder laser = Button(17) #Die Zahl entspricht dem Pin auf dem ARPI600 Board sound = Button(18, pull_up=True) rotate = RotaryEncoder(21, 20) +tilt = Button(23) def score(x): pass def command_tilt(): - action = input() - if action == "0": + print("waiting to get tilted...") + 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 else: return -1 @@ -63,7 +67,7 @@ def main(): result = 0 sound.when_held = sound_was_held 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: score += result # war zuerst zwei Zeilen weiter unten, hat dann aber nach einer falschen Runde den Score erhöht time.sleep(0.5) @@ -75,4 +79,4 @@ def main(): -main() \ No newline at end of file +main()