![Keywish ATMEGA328P-PU Instruction Manual Download Page 41](http://html.mh-extra.com/html/keywish/atmega328p-pu/atmega328p-pu_instruction-manual_1962647041.webp)
41
First, ordinary notes. Take 1 shot.
Second, underlined notes indicate 0.5 beats; two underscores are quarter beats (0.25)
Third, some notes are followed by a dot, which means that 0.5 more shots are added, that is, 1 + 0.5.
Fourth, some notes are followed by a "-", which means that 1 more shot is added, that is, 1 + 1.
So we can give each note a play like this, and the music becomes. Basic music knowledge is all right,
and many don't understand it. After all, it is a music idiot. So I understand that. As for the conversion of the
beat to the frequency, there is also a corresponding table, just follow table two:
Music beat
1/4 beat delay time
Music
1/8 beat delay time
4/4
125ms
4/4
62ms
3/4
187ms
3/4
94ms
2/4
250ms
2/4
125ms
Table 2: Beat and frequency correspondence table
It is also achieved through the delay function,of course there will be errors. The idea of programming is
very simple, firstly convert the note frequency and the time you want to sing into the two arrays. Then in the
main programming, through the delay function to reach the corresponding frequency . sing it over, stop for a
while, and then sing it, all the conversion is complete, we get the following frequency (Table 3) and beat:
Do 262 Re 294
Mi 330
Fa 349
Sol 392
La 440
Si 494
Do_h 523
Si_h 988
Mi_h 659
La_h 880 Sol_h 784 Fa_h698
Re_h 587
Table 3: Happy Birthday Song beat table
According to the music score, we can get the frequency of the birthday song
:
Sol,Sol,La,Sol,Do_h,Si,Sol,Sol,La,Sol,Re_h,Do_h,Sol,Sol,Sol_h,Mi_h,Do_h,Si,La,Fa_h,Fa_h
,Mi_h,Do_h,Re_h,Do_hfloat
The beat is as follows:
0.5,0.5,1,1,1,1+1,0.5,0.5,1,1,1,1+1,0.5,0.5,1,1,1,1,1,0.5,0.5,1,1,1,1+1,
Add beats and frequency to the program and download it to Arduino to play.
Happy Birthday music score beat, view table two rhythm and frequency corresponding table 1 beats time is
187*4 = 748ms
Note: The procedure is shown in the:
“
Lesson\Module_Test\Buzzer_Test\Happy_Birthday\Happy_Birthday.ino
”
#define BUZZER_PIN 9
//buzzer pin 9
#define RGB A1
//RGB pin A1
#define Do 262
#define Re 294
#define Mi 330
#define Fa 349
#define Sol 392