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

# semaphore initialized to 0 -> red: if a thread tries to acquire the semaphore

               # it blocks if the semaphore has not been turned ‘green’ (released)

               semaphore = threading.Semaphore(0)


               # define a RTTTL Halloween melody to be played by passing it the RTTTL string.

               # find more songs at http://ez4mobile.com/nokiatone/rtttf.htm and many other websites
               hsong  =  rtttl.tune(‘Halloween:d=4,o=5,b=180:8d6,8g,8g,8d6,8g,8g,8d6,8g,8d#6,8g,8d6,8g,8g,8d6,8g,8g,-
           8d6,8g,8d#6,8g,8c#6,8f#,8f#,8c#6,8f#,8f#,8c#6,8f#,8d6,8f#,8c#6,8f#,8f#,8c#6,8f#,8f#,8c#6,8f#,8d6,8f#’)



               # If you use Particle Photon uncomment the following line and short-circuit the Buzzer and Aux2 pins
               # toishield.buzzer_pin=D9.PWM



               def blink():

                   # blink while the pumpkin is active

                   while toishield.microphone.activePumpkin:
                       leds.setall(255,0,0)

                       leds.on()

                       sleep(500)

                       leds.setall(255,140,0)

                       leds.on()
                       sleep(500)

                   leds.setall(0,0,0)

                   leds.on()
                   semaphore.release()




                                                                                                                     311
   314   315   316   317   318   319   320   321   322   323   324