-
Notifications
You must be signed in to change notification settings - Fork 9
Open
Description
Hi,
I have copied your code (actually I have simplified it a little) and I have had an issue : the last note of the songs was not played and i had a dreadfull noise during few seconds (like when you call a fax with an old fashion phone). I think I get the answer :
The lines for in the songs functions are wrong : you use sizeof to find the size of the array, but it does not give you the number of elements, but the size (in bite) of the object. I made the following correction and it nearly work (it does not play the last note for some reason) :
`
int sariaSongArray[] = {_F4, _A4, _B4, _F4, _A4, _B4, _F4, _A4, _B4, _E5, _D5, _B4, _C5, _B4, _G4, _E4, _D4, _E4, _G4};
int sariaSongDelay[] = {250, 250, 500, 250, 250, 500, 250, 250, 250, 250, 500, 250, 250, 250, 250, 625, 250, 250, 250};
int sariaSongSize = sizeof(sariaSongArray)/sizeof(sariaSongArray[0]);
for(int i = 0;i < sariaSongSize;i++){
tone(speakerPin, sariaSongArray[i]);
delay(sariaSongDelay[i]);
}
`
Hope I helped
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
No labels