Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

How long does Program Example 4.7 take to play through the tune once? Calculate

ID: 3890739 • Letter: H

Question

How long does Program Example 4.7 take to play through the tune once? Calculate

this by checking the program, then measure it as the program plays.

/*Program Example 4.7: Plays the tune "Oranges and Lemons" on a piezo buzzer, using PWM #include "mbed.h" PwmOut buzzer (p26); //frequency array float frequency[]=(659, 554,659,554 ,440,494 , 554,587 ,494,659 , 554,440); float beat [ ]=(1,1,1,1,1,0,5,0·5,1,1,1,1,2); int main() //beat array while (1) (int buzzer.period (1/(2*frequency[i])); buzze r=0 . 5 ; wait ( , 4*beat [ i ] ) ; for 1-0 ; i

Explanation / Answer

Considering that wait is only responsible for delay and and all other code (instruction fetch, loop constraint checking, assignment etc) does not take any time.

Total wait time: 0.4*[1+1+1+1+1+0.5+0.5+1+1+1+1+2] sec = 4.8 sec

So going through the document it should take 4.8 secs



Reality: It took little more than 5secs

Your question is being answered by our experts. It may take maximum of 1 hour. So please be patient till the the question is being answered. We appreciate your patience

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote