With Xmas nearly upon us, it might be a nice idea to build a library of Christmas carols that can be played on a PIC. So if you have a tune you'd like to add, please do.

Here's one to get you started:

Code:
'****************************************************************
'*  Name    : Jingle Bells.BAS                                  *
'*  Author  : David Taylor (LEDave)                             *
'*  Notice  : Copyright (c) 2010 [select VIEW...EDITOR OPTIONS] *
'*          : All Rights Reserved                               *
'*  Date    : 14/12/2010                                        *
'*  Version : 1.0                                               *
'*  Notes   : For a 16F684 easily adapted  though               *
'*          :                                                   *
'****************************************************************
ANSEL   = %00000000    'Disable analog select so ports work as digital i/o.
CMCON0  = %00000111    'Disable analog comparators.
TRISA   = %00000000    'Set PORTA as OUTPUT.
PORTA   = %00000000    'Set PORTA pins all low.
TRISC   = %00000000    'Set PORTC as OUTPUT.
PORTC   = %00000000    'Set PORTC pins all low.
@ __config _INTRC_OSC_NOCLKOUT & _WDT_OFF & _MCLRE_ON
                 
MPIN VAR PORTA.5 'Pos+ side of Sounder attached here.

Y VAR BYTE  'Note delay time VAR

MAIN:
' @ SLEEP   'Put the PIC to sleep until MCLRE pressed.
' @ NOP     


START: 
PAUSE 150     
 LET  y = 4 'Delay between notes = 28 mSec
Sound MPIN, [98,30,0,Y,98,30,0,Y,98,70,0,Y,98,30,0,Y,98,30,0,Y,98,70,0,Y,98,30,0,Y,102,30,0,Y]
SOUND MPIN, [90,30,0,Y,94,30,0,Y,98,70,0,Y,99,30,0,Y,99,30,0,Y,99,50,0,Y,99,10,0,Y,99,30,0,Y] 
sound mpin, [98,30,0,Y,98,40,0,Y,98,10,0,Y,98,10,0,Y,98,30,0,Y,94,30,0,Y,94,30,0,Y,98,30,0,Y,94,60,0,Y,102,80,0,y]      
Sound MPIN, [98,30,0,Y,98,30,0,Y,98,70,0,Y,98,30,0,Y,98,30,0,Y,98,70,0,Y,98,30,0,Y,102,30,0,Y]
SOUND MPIN, [90,30,0,Y,94,30,0,Y,98,70,0,Y,99,30,0,Y,99,30,0,Y,99,50,0,Y,99,10,0,Y,99,30,0,Y] 
SOUND MPIN, [98,30,0,Y,98,40,0,Y,98,10,0,Y,98,10,0,Y,102,30,0,Y,102,30,0,Y,99,30,0,y,94,30,0,y,90,80,0,y]
pause 250 'Second verse
SOUND MPIN, [90,30,0,Y,105,30,0,Y,102,30,0,Y,99,30,0,Y,90,70,0,Y,90,10,0,Y,90,10,0,Y,90,30,0,Y,105,30,0,Y,102,30,0,Y,99,30,0,Y,94,70,Y]
SOUND MPIN, [94,30,0,Y,107,30,0,Y,105,30,0,Y,102,30,0,Y,98,70,0,Y,109,30,0,Y,109,30,0,Y,107,30,0,Y,102,30,0,Y,105,70,0]
SOUND MPIN, [90,30,0,Y,105,30,0,Y,102,30,0,Y,99,30,0,Y,90,70,0,Y,90,10,0,Y,90,10,0,Y,90,30,0,Y,105,30,0,Y,102,30,0,Y,99,30,0,Y,94,70,Y]
SOUND MPIN, [94,40,0,Y,107,30,0,Y,105,30,0,Y,102,30,0,Y,109,30,0,Y,109,30,0,Y,109,30,0,Y,111,30,0,Y,109,30,0,Y,107,30,0,Y,102,30,0,Y,99,100,0,Y]
GOTO MAIN
Dave