From e995f4f89eecc13328a01bc937c99371b0d4a0c7 Mon Sep 17 00:00:00 2001 From: John Edgar Park Date: Mon, 1 Oct 2018 18:19:15 -0700 Subject: [PATCH] fixed pwm setup and while audio.playing loop --- HalloWing_Jump_Scare_Trap/hallowing_jump_scare_trap.py | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/HalloWing_Jump_Scare_Trap/hallowing_jump_scare_trap.py b/HalloWing_Jump_Scare_Trap/hallowing_jump_scare_trap.py index 834a3acf3..7fc41c9a5 100644 --- a/HalloWing_Jump_Scare_Trap/hallowing_jump_scare_trap.py +++ b/HalloWing_Jump_Scare_Trap/hallowing_jump_scare_trap.py @@ -21,7 +21,7 @@ led = digitalio.DigitalInOut(LED_PIN) led.direction = digitalio.Direction.OUTPUT # Setup servo # servo = pulseio.PWMOut(board.D4, frequency=50) -pwm = pulseio.PWMOut(board.D4, duty_cycle=2 ** 15, frequency=50) +pwm = pulseio.PWMOut(board.D4) servo = servo.Servo(pwm) # Setup cap touch button @@ -39,10 +39,11 @@ def play_wave(): wave_file = open("hiss01.wav", "rb") # open a wav file wave = audioio.WaveFile(wave_file) audio.play(wave) # play the wave file + led.value = True + servo_release() + print('Motion detected!') while audio.playing: # turn on LED, turn servo - led.value = True - servo_release() - print('Motion detected!') + pass wave_file.close() # close the wav file # Setup audio out pin audio = audioio.AudioOut(board.A0)