Hi Trying. Hi Steve. Using the PWM module is a BIG improvement as each note will be perfectly on key. I converted some tunes into HPWM commands to play music on one of the PWM ports on a 16F818. The 818 can hold about 2 or 3 songs, the 16F819 can hold about 5 and a 16F88 that I used holds 8 different tunes. Below are 2 of them. If you want more volume, output the CCP1 pin to the gate of a FET. Source to ground and speaker from drain to B+. It will be painfully loud. I used a logic-level IRLZ44N at 3 Volts for this. Add the command CCP1CON = 0 and make the port LOW at the end of the song otherwise the FET may be left ON and kill the battery. CAUTION - writing songs and playing them on a PIC can be addicting! Be prepared to spend countless hours writing code.
BABABLACKSHEEP:
HPwm 1,127,262:Pause 320
HPwm 1,127,262:Pause 320
HPwm 1,127,392:Pause 320
HPwm 1,127,392:Pause 320
HPwm 1,127,440:Pause 160
HPwm 1,127,494:Pause 160
HPwm 1,127,523:Pause 160
HPwm 1,127,440:Pause 160
HPwm 1,127,392:Pause 320
HPwm 1,127,000:Pause 320
HPwm 1,127,349:Pause 320
HPwm 1,127,349:Pause 320
HPwm 1,127,330:Pause 320
HPwm 1,127,330:Pause 320
HPwm 1,127,294:Pause 320
HPwm 1,127,294:Pause 320
HPwm 1,127,262:Pause 320
Pause 1000
GoTo BABABLACKSHEEP
STARSPANGLEDBANNER:
HPwm 1,127,698:Pause 320
HPwm 1,127,587:Pause 320
HPwm 1,127,466:Pause 640
HPwm 1,127,587:Pause 640
HPwm 1,127,698:Pause 640
HPwm 1,127,932:Pause 640
HPwm 1,127,000:Pause 640
HPwm 1,127,1175:Pause 320
HPwm 1,127,1047:Pause 320
HPwm 1,127,932:Pause 640
HPwm 1,127,587:Pause 640
HPwm 1,127,659:Pause 640
HPwm 1,127,698:Pause 640
HPwm 1,127,000:Pause 320
HPwm 1,127,698:Pause 320
HPwm 1,127,698:Pause 320
HPwm 1,127,1175:Pause 640
HPwm 1,127,1047:Pause 320
HPwm 1,127,932:Pause 640
HPwm 1,127,880:Pause 640
HPwm 1,127,000:Pause 640
HPwm 1,127,784:Pause 320
HPwm 1,127,880:Pause 320
HPwm 1,127,932:Pause 640
HPwm 1,127,932:Pause 640
HPwm 1,127,698:Pause 640
HPwm 1,127,587:Pause 640
HPwm 1,127,466:Pause 640
Pause 1000
GOTO STARSPANGLEDBANNER




Bookmarks