Professional Documents
Culture Documents
Why spend $10.00 on a Happy Birthday musical card when you can produce the tune yourself.
This project uses just 4 components and a small prototype PC board to produce a project that will teach you a lot
about programming.
The circuit uses a piezo diaphragm connected to pins 3 and 5.
That's the only component.
All the work is done by the program.
The project is so easy, we don't need to provide any construction details.
;**********************************************
;HAPPY BIRTHDAY TUNE *
; 11-5-2010 *
; *
;**********************************************
list p=12F629
radix dec
include "p12f629.inc"
;===============================
;
; Configuration Bits
;
;===============================
;
***************************************************************
*
;Beginning of program
;
***************************************************************
*
org 0x00
nop
nop
nop
nop
nop
SetUp bsf status, rp0 ;Bank 1
call 0x3FF ;retrieve calibration value
movwf OSCCAL ;
movlw b'00001011' ;Set TRIS
movwf TRISIO ;GP2,4 outputs
bcf status, rp0 ;bank 0
movlw 07h ;turn off Comparator
movwf CMCON ;must be placed in bank 0
clrf jump ;jump value for table
goto M1
;
***************************************************************
*
;* Delays *
;
***************************************************************
*
gap_1 movlw .2
movwf gapDela
gap_1a decfsz tempA
goto gap_1a
decfsz gapDela,1 ;produces loops
goto gap_1a
decfsz gap,1 ;
goto gap_1
retlw 00
_250mS nop
goto $+1
decfsz D1,1
goto _250mS
decfsz D2,1
goto _250mS
retlw 00
;********************************
;* Table *
;********************************
retlw 0FFh
M1 call _250mS
call _250mS
END
GOING FURTHER
This project provides you with the tools to create your own tune or download one of the "old favourites" and
annoy everyone in the household with its incessant playing.