DIY HACK - HOWTO make some sounds with Arduino! diy哈克-如何作出一些聲音與伊諾! Sound Part 3 - Playing a Melody良好的第3部分-發揮了旋律

Check out the簽出 Part 3 of “HOWTO make sounds with Ardunio” and learn to play melody第3部分“如何使聲音與ardunio ”和學習中發揮的旋律 . 。
Bit-Banging Sound比特砰砰聲
To bit-bang sound we toggle an output pin at the desired frequency.以位元邦健全,我們切換1輸出引腳在理想的頻率。 To play a musical note, we need to use specific frequencies and play the sound for a specific amount of time.扮演一個音符,我們需要使用特定的頻率和發揮的聲音為某一特定數額的時間。Generating the desired frequency big-bang style means figuring out what the period or cycle time of the desired frequency is.發電所需的頻率大爆炸式的手段,搞清楚什麼時期或週期時間所期望的頻率。 This is easy to calculate, it’s the reciprocal (1/F) of the frequency.這是很容易計算,它的交互( 1 / f )的頻率。 As we found in part 2, 1KHz is 1000 cycles per second.正如我們發現在第2部分, 1千赫,是1000赫茲。 So, one cycle takes 1 one-thousandth (1/1000) of a second or 0.001 seconds (1 millisecond).所以,一個週期需要1 1 -千分之一( 1 / 1000 )第二次或0.001秒( 1毫秒) 。 We need to toggle the pin at this rate so we want to keep it low for 1/2 the time then high for 1/2 the time.我們需要切換引腳在這個率,所以我們希望保持它的低,為1 / 2的時間,然後高為1 / 2的時間。 Therefore we want to set the I/O pin low for 500uS, then high for 500uS and do this over and over for as long as the duration requires.因此,我們要設置I / O引腳低為500us ,那麼高為500us ,以及這樣做以上和超過因為只要時間要求。
Related Posts:相關文章:

HOWTO make Beer Thermostat with Arduino如何使啤酒恆溫與伊諾

Here’sa cool audio and video controller DIY using Arduino.以下是冷靜的音頻和視頻控制器diy使用伊諾。






















