Answered step by step
Verified Expert Solution
Question
1 Approved Answer
Write a C program for the Arduino Mega SBC which will monitor the keyboard for inputs of A, B, C, D, E, F, and
Write a C program for the Arduino Mega SBC which will monitor the keyboard for inputs of A, B, C, D, E, F, and G. Depending upon which key was pressed use the timer to generate a square wave on PortB.6 of the ATmega2560 (Arduino Digital pin 12) of the appropriate frequency for the middle octave of that musical note (see Table). The note should last until another key is pressed; at which time the new note will be played. If the 'q' key is pressed the note will stop playing. For debugging purposes, use of the Arduino Serial Library is permitted for this lab. Use the file serial_echo example.ino as an example of serial I/O. YOUR C PROGRAM MUST CONTAIN A FUNCTION WHICH TAKES THE FREQUENCY AS AN INPUT, AND THEN CONFIGURES AND RUNS THE TIMER. THIS FUNCTION MUST WORK FOR ALL NOTES LISTED IN THE TABLE, IT DOES NOT HAVE TO WORK FOR ALL POSSIBLE FREQUENCIES. HINT: You can probably write a single subroutine which outputs the notes and checks for input. Then, you can call this single subroutine with different timer "load" values for the different notes. A 440 A# 466 B 494 523 C# 554 587 D# 624 E 659 F 749 G 784 G# 831
Step by Step Solution
★★★★★
3.52 Rating (149 Votes )
There are 3 Steps involved in it
Step: 1
int Spin 12 s pin int len 11 num of notes char notes ccggaagffeeddc ...Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started