10.07.2015 Views

cubloc_manual2.pdf

cubloc_manual2.pdf

cubloc_manual2.pdf

SHOW MORE
SHOW LESS

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

Const Device = CB280Low 5Freqout 0,4403Delay 200Freqout 0,3703Delay 200Freqout 0,3114Delay 200Freqout 0,2202Delay 200Pwmoff 0이 기능을 이용하여 음악을 연주할 수 있는 프로그램을 작성해 보았습니다.옥타브 4 옥타브 5라 시 도 레 미 파 솔 라 시 도 레 미 파 솔A B C D E F G H I J K L M N한 음을 2 개의 캐릭터로 표현하는데, 옥타브에 따라서 다른 알파벳으로 음계를 적어주고, 이어서숫자로된 음 길이를 적어줍니다. 음 길이 숫자가 클수록 음의 길이도 길어지게 됩니다.Const Device = cb280Dim PLAYSTR As StringLow 5PLAYSTR = "G5E3E3G3E3C5"PLAY 0,PLAYSTRDoLoopEndSub PLAY(CH As Byte,NOTE As String)Dim PL As ByteDim CHAR As ByteConst Integer PLAYTABLE = (5236,4665,4403,3923,3495,3299,2939,2618,2333,2202,1961,1747,1649,1469,0)For PL=1 To Len(NOTE) Step 2CHAR = Asc(Mid(NOTE,PL,1)) - &H41Freqout CH,PLAYTABLE(CHAR)CHAR = Asc(Mid(NOTE,PL+1,1)) - &H30Delay CHAR*100NextPwmoff CHEnd Sub만약 PWM 관련 포트를 다른 용도로 사용하고 있을때에는 Freqout 명령을 사용할 수 없게 됩니다.409

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!