In this project an audio signal is generated to provide a tone of a required frequency. The tones are generated by the hardware timer of the microcontroller. The microcontroller used in this project is the ATTiny2313. Also the duration of the tone can be specified. When a sequence of tones with a specified duration is played by the microcontroller, it can create any music you want.
The purpose of this project is to build a circuit that can play music stored in the memory of the microcontroller. The music is generated by playing a sequence of tone and duration pairs. The microcontroller reads the pair from the memory and generates a tone with a specified duration. The hardware of the project is a circuit that is based on the ATTiny2313 microcontroller. For this project we use the ATTiny2313 board, which can be purchased at www.bizztronix.eu.The project uses a small speaker, which is driven by an NPN transistor.
The circuit is simple, a transisitor is via a resitor connected to PORTB.2 of the ATTiny2313 which is the output of the PWM hardware timer. The transistor amplifies the signal. The circuit can be build on a breadboard and connected to the ATTiny2313 board.
A tone consist of notes and their duration. A note is a particular frequency which comes out of the loudspeaker for a certian duration. In this code a tone is saved in a structure with the elements frequency and duration in milli seconds of the datatype unsigned integer.