The video below was taken at a laboratory in the Temasek Engieering School. The student Arul, domonstrated his project- A kitchen timer with preset durations. The device is embedded with PIC18F4520.
JUKEBOX: Source code for Jukebox using Timer0 interrupts as time signature control and PWM for note generation. Source Code: /*Program Name: Jukebox Author: TY Lew This program generates a tune at the piezo speaker of PICDEM2 Plus. It uses PWM to generate each note and timer0 interrupt to execute the time signature of each note. Thus, the PR2 is updated with the value upon each inetrrupt. Whereas, the CCPR1L simple updated with PR2/2 for 50-50 mark-space ratio. The CCP1CON<5:4> is ignore as we do not need such accuracy for the tones. The 'note' array determines the tone frequecy of the notes that will go into PR2. The number is the MIDI notation. The 'tmsig' array determines the duration of each note and will be used to update timer registers. The larger the value the longer is the duration. In general the sytem goes into the ISR for every tone played. */ /* Pressing RA4 button toggles the sound tune on and off */ #include <xc.h> #include <stdlib.h>
Comments