The Annoy (A Tiny Intelligent Buzzer)

Tone Generation Theory
           The purpose of the annoy is to annoy through simple tones. To make a microcontroller output a tone to the speaker we need to generate what is called a PWM signal. This is an alternating signal that changes back and forth between Vcc and Ground. The frequency that this PWM signal is output from the microcontroller will determine the pitch of the tone. High frequencies mean a higher more annoying tone, lower frequencies mean a lower more subtle tone.

PWM Formulas

           The picture above illustrates a typical PWM signal and shows you how to calculate the frequency that it has based off of how long the signal is in an 'on' state and in an 'off' state for the C4 music tone. Use these formulas to figure out what tones you want to generate. Remember the 10F202 internal oscillator is 4 MHz and a PIC takes 4 clock cycles per instruction.