Page 320 - Tasarım Beceri Atölyeleri Öğretmen El Kitabı
P. 320

def playHalloween():

                   # plays halloween song two times, then disables pumpkin, but also waits
                   # at the semaphore to synchronize with blinking thread

                   for i in range(2):

                       hsong.play(toishield.buzzer_pin)
                   toishield.microphone.activePumpkin = False

                   semaphore.acquire()

                   sleep(1000)

                   print(“enabled again”)

                   toishield.microphone.detectionEnabled = True



               def scare():

                   # this is called when the sound exceeds the threshold, waits one second

                   # and starts scaring!
                   sleep(1000)

                   thread(playHalloween)

                   thread(blink)

               # define a function that takes a sensor object as parameter and checks the
               # maximum peak to peak extension of the signal in a preset window

               # look at this

               # example for details on how the sound detector works








           312
   315   316   317   318   319   320   321   322   323   324   325