2016年9月18日 星期日

程式集訓 F010:溢出字元-beep

#coding=utf8

#程式集訓  F010:溢出字元-beep
'''
題目:(F010) 溢出字元-beep : 輸出相同的字串及聲音

Escape Sequence Meaning
\newline Ignored
\\ Backslash (\)
\' Single quote (')
\" Double quote (")
\a ASCII Bell (BEL)
\b ASCII Backspace (BS)
\f ASCII Formfeed (FF)
\n ASCII Linefeed (LF)
\r ASCII Carriage Return (CR)
\t ASCII Horizontal Tab (TAB)
\v ASCII Vertical Tab (VT)
\ooo ASCII character with octal value ooo
'''
#\xhh.... ASCII character with hex value hh....

#If you're on a Unix terminal, you can print "\a" to get a terminal bell:
def beep():
      print ("\a")

for i in range (0,10):
    beep()
#=======================================
import winsound         # for sound
import time             # for sleep

Freq = 2500 # Set Frequency To 2500 Hertz
Dur = 1000 # Set Duration To 1000 ms == 1 second
winsound.Beep(Freq,Dur)
time.sleep(0.25)        # in seconds (0.25 is 250ms)

winsound.Beep(440, 250) # frequency, duration
time.sleep(0.25)        # in seconds (0.25 is 250ms)

winsound.Beep(600, 250)
time.sleep(0.25)

沒有留言:

張貼留言

2024_09 作業3 以Node-Red 為主

 2024_09 作業3  (以Node-Red 為主  Arduino 可能需要配合修改 ) Arduino 可能需要修改的部分 1)mqtt broker  2) 主題Topic (發行 接收) 3) WIFI ssid , password const char br...