Karl Stein
Better Music Box (Embedded Systems)
This embedded system uses the Timer0, and Timer1, and Timer1 Compare interrupts to create a music box.
Timer1 Compare is used for setting the frequency of the note. Timer0 is used for setting the duration of the note. The music box will have a frequency range of 20 – 2000Hz ±1% and the acceptable duration will be 1 – 10 seconds. The user will use the keypad to first enter the frequency 20 – 2000. * will push the first number into the frequency row, when the second number is input and submitted the desired note will play for the desired duration. # will backspace the current user value. If the user exceeds 2000Hz the system will immediately clear the user input. If the user tries to enter a frequency lower than 20Hz the system will ignore them. If the frequency is already input, the value for time will immediately clear if the user goes above 10. The frequency will be output on PORTA pin 1 which is connected to a follower Op-amp circuit that powers an 8-ohm speaker. A pocket Oscilloscope will be used to measure the frequency of the note.
This is the flowchart for the main loop of code

This is the flowchart for the interrupts being used

Code snippet 1

Code snippet 2

Code snippet 3

Oscilloscope verification of the system



Demonstration Video