So I'll start from the basics.
The rate of high/low signals sent to the speaker from the microcontroller is called the frequency - it determines the tone or pitch of the beep.
Each time a high/low repeats itself is called a cycle - Number of cycles per second (reffered to as Herts, Hz)
The Piezoelectric speaker:
In this activity I will be experimenting with sending some different signals to the Piezoelectric speaker.
Piezoelectric Speaker Schematic symbol and drawing.
First of all, I built this simple circuit -
How does the Piezo Speaker work?
When a guital string vibrates it causes change in air pressure, and these changes in air pressure are what your ear detects as a tone. The faster the change in air pressure the higher the pitch, and the slower the change, the lower the pitch.
When high/low signals are applied to the speakers positive terminal, the element inside the piezo speaker, called the piezoelectric element, it vibrates, and causes changes in air pressure.
Programming speaker control:
The FREQOUT command is a convenient way of sending high/low signals to a speaker to make sound.
FREQOUT command syntax -
FREQOUT Pin, Duration, Freq1 {, Freq2}
Pin - Value you can use to choose what I/O pin to use.
Duration - Value that tells the FREQOUT command how long the tone should play for (in milliseconds).
Freq1 - Argument is used to set the frequency of the tone, in Herts.
Freq2 - An optional Freq2 argument that can be used to mix frequencies.
This is the first test that I did on a Piezoelectric Speaker -
And the coding -
Here are a fiew ActionTones -
Coding -
Mixing Tones:
When you mix 2000 Hz with 20001 Hz, the tone will fade in and out once every second, at a frequency of 1 Hz. If you mix 2000 Hz with 2002 Hz, it will fade in and out twice a second, and so on.
Mixing Tones Video -
Coding for MixingTones -
I did some programming on that but whats coming up next is the real stuff so check it out -
Musical Notes and Songs:
This is basically an electronic piano. Rightmost piano keys and their frequencies.
With this, you can create any song, using the FREQOUT command.
Here's some music for you -
DoReMiFaSolLaTiDo:
Coding -
This is the part that gets pretty complicated, but its pretty cool -
Storing and Retrieving sequence of Musical notes:
A good way of saving musical notes is to store them in the EEPROM. (Electrically Erasable Programmable Read-Only Memory). To do this use the DATA diractive.
Syntax for the DATA diractive -
{Symbol} DATA {Word} DataItem {, {Word} DataItem,...}
Here is an example of how to use the DATA diractive to store the characters that corespond to musical notes:
Notes DATA "C","C","G","G","A","A","G"
This is what I put up so far today, I'll put up the rest later or another day.
.bmp)
.bmp)
.bmp)
.bmp)
.bmp)
No comments:
Post a Comment