{"id":16442,"date":"2022-10-27T00:23:59","date_gmt":"2022-10-27T04:23:59","guid":{"rendered":"https:\/\/courses.ideate.cmu.edu\/60-223\/f2022\/work\/?p=16442"},"modified":"2022-10-27T00:23:59","modified_gmt":"2022-10-27T04:23:59","slug":"metronome","status":"publish","type":"post","link":"https:\/\/courses.ideate.cmu.edu\/60-223\/f2022\/work\/metronome\/","title":{"rendered":"Metronome"},"content":{"rendered":"<p style=\"text-align: left\"><span style=\"font-weight: 400\">This metronome functions as a musician\u2019s tool to easily control beats per minute, switch between time signatures, as well as adjust volume using buttons and potentiometers for a range of possibilities when practicing.<\/span><\/p>\n<h3 style=\"text-align: center\">Close Up<\/h3>\n<div id=\"attachment_16461\" style=\"width: 630px\" class=\"wp-caption aligncenter\"><img aria-describedby=\"caption-attachment-16461\" loading=\"lazy\" class=\"wp-image-16461 size-large\" src=\"https:\/\/courses.ideate.cmu.edu\/60-223\/f2022\/work\/wp-content\/uploads\/2022\/10\/metronome-detail-1-1024x768.png\" alt=\"\" width=\"620\" height=\"465\" srcset=\"https:\/\/courses.ideate.cmu.edu\/60-223\/f2022\/work\/wp-content\/uploads\/2022\/10\/metronome-detail-1-1024x768.png 1024w, https:\/\/courses.ideate.cmu.edu\/60-223\/f2022\/work\/wp-content\/uploads\/2022\/10\/metronome-detail-1-300x225.png 300w, https:\/\/courses.ideate.cmu.edu\/60-223\/f2022\/work\/wp-content\/uploads\/2022\/10\/metronome-detail-1-768x576.png 768w, https:\/\/courses.ideate.cmu.edu\/60-223\/f2022\/work\/wp-content\/uploads\/2022\/10\/metronome-detail-1-1536x1152.png 1536w, https:\/\/courses.ideate.cmu.edu\/60-223\/f2022\/work\/wp-content\/uploads\/2022\/10\/metronome-detail-1-2048x1536.png 2048w, https:\/\/courses.ideate.cmu.edu\/60-223\/f2022\/work\/wp-content\/uploads\/2022\/10\/metronome-detail-1-973x730.png 973w, https:\/\/courses.ideate.cmu.edu\/60-223\/f2022\/work\/wp-content\/uploads\/2022\/10\/metronome-detail-1-508x381.png 508w\" sizes=\"(max-width: 620px) 100vw, 620px\" \/><p id=\"caption-attachment-16461\" class=\"wp-caption-text\">On\/Off Button, Volume Control, and LCD Displaying BPM and Time Signature<\/p><\/div>\n<div id=\"attachment_16464\" style=\"width: 630px\" class=\"wp-caption aligncenter\"><img aria-describedby=\"caption-attachment-16464\" loading=\"lazy\" class=\"wp-image-16464 size-large\" src=\"https:\/\/courses.ideate.cmu.edu\/60-223\/f2022\/work\/wp-content\/uploads\/2022\/10\/metronome-detail-2-1-1024x768.png\" alt=\"\" width=\"620\" height=\"465\" srcset=\"https:\/\/courses.ideate.cmu.edu\/60-223\/f2022\/work\/wp-content\/uploads\/2022\/10\/metronome-detail-2-1-1024x768.png 1024w, https:\/\/courses.ideate.cmu.edu\/60-223\/f2022\/work\/wp-content\/uploads\/2022\/10\/metronome-detail-2-1-300x225.png 300w, https:\/\/courses.ideate.cmu.edu\/60-223\/f2022\/work\/wp-content\/uploads\/2022\/10\/metronome-detail-2-1-768x576.png 768w, https:\/\/courses.ideate.cmu.edu\/60-223\/f2022\/work\/wp-content\/uploads\/2022\/10\/metronome-detail-2-1-1536x1152.png 1536w, https:\/\/courses.ideate.cmu.edu\/60-223\/f2022\/work\/wp-content\/uploads\/2022\/10\/metronome-detail-2-1-2048x1536.png 2048w, https:\/\/courses.ideate.cmu.edu\/60-223\/f2022\/work\/wp-content\/uploads\/2022\/10\/metronome-detail-2-1-973x730.png 973w, https:\/\/courses.ideate.cmu.edu\/60-223\/f2022\/work\/wp-content\/uploads\/2022\/10\/metronome-detail-2-1-508x381.png 508w\" sizes=\"(max-width: 620px) 100vw, 620px\" \/><p id=\"caption-attachment-16464\" class=\"wp-caption-text\">Speaker, BPM Control, Time Signature Button<\/p><\/div>\n<div id=\"attachment_16466\" style=\"width: 630px\" class=\"wp-caption aligncenter\"><img aria-describedby=\"caption-attachment-16466\" loading=\"lazy\" class=\"size-large wp-image-16466\" src=\"https:\/\/courses.ideate.cmu.edu\/60-223\/f2022\/work\/wp-content\/uploads\/2022\/10\/metronome-interacting-time-sig-1024x819.png\" alt=\"\" width=\"620\" height=\"496\" srcset=\"https:\/\/courses.ideate.cmu.edu\/60-223\/f2022\/work\/wp-content\/uploads\/2022\/10\/metronome-interacting-time-sig-1024x819.png 1024w, https:\/\/courses.ideate.cmu.edu\/60-223\/f2022\/work\/wp-content\/uploads\/2022\/10\/metronome-interacting-time-sig-300x240.png 300w, https:\/\/courses.ideate.cmu.edu\/60-223\/f2022\/work\/wp-content\/uploads\/2022\/10\/metronome-interacting-time-sig-768x614.png 768w, https:\/\/courses.ideate.cmu.edu\/60-223\/f2022\/work\/wp-content\/uploads\/2022\/10\/metronome-interacting-time-sig-1536x1229.png 1536w, https:\/\/courses.ideate.cmu.edu\/60-223\/f2022\/work\/wp-content\/uploads\/2022\/10\/metronome-interacting-time-sig-2048x1639.png 2048w, https:\/\/courses.ideate.cmu.edu\/60-223\/f2022\/work\/wp-content\/uploads\/2022\/10\/metronome-interacting-time-sig-973x778.png 973w, https:\/\/courses.ideate.cmu.edu\/60-223\/f2022\/work\/wp-content\/uploads\/2022\/10\/metronome-interacting-time-sig-508x406.png 508w\" sizes=\"(max-width: 620px) 100vw, 620px\" \/><p id=\"caption-attachment-16466\" class=\"wp-caption-text\">Turning Potentiometer to Control BPM (beats per minute)<\/p><\/div>\n<div id=\"attachment_16465\" style=\"width: 630px\" class=\"wp-caption aligncenter\"><img aria-describedby=\"caption-attachment-16465\" loading=\"lazy\" class=\"wp-image-16465 size-large\" src=\"https:\/\/courses.ideate.cmu.edu\/60-223\/f2022\/work\/wp-content\/uploads\/2022\/10\/metrome-interacting-time-signature-1024x625.png\" alt=\"\" width=\"620\" height=\"378\" srcset=\"https:\/\/courses.ideate.cmu.edu\/60-223\/f2022\/work\/wp-content\/uploads\/2022\/10\/metrome-interacting-time-signature-1024x625.png 1024w, https:\/\/courses.ideate.cmu.edu\/60-223\/f2022\/work\/wp-content\/uploads\/2022\/10\/metrome-interacting-time-signature-300x183.png 300w, https:\/\/courses.ideate.cmu.edu\/60-223\/f2022\/work\/wp-content\/uploads\/2022\/10\/metrome-interacting-time-signature-768x469.png 768w, https:\/\/courses.ideate.cmu.edu\/60-223\/f2022\/work\/wp-content\/uploads\/2022\/10\/metrome-interacting-time-signature-1536x937.png 1536w, https:\/\/courses.ideate.cmu.edu\/60-223\/f2022\/work\/wp-content\/uploads\/2022\/10\/metrome-interacting-time-signature-2048x1250.png 2048w, https:\/\/courses.ideate.cmu.edu\/60-223\/f2022\/work\/wp-content\/uploads\/2022\/10\/metrome-interacting-time-signature-973x594.png 973w, https:\/\/courses.ideate.cmu.edu\/60-223\/f2022\/work\/wp-content\/uploads\/2022\/10\/metrome-interacting-time-signature-508x310.png 508w\" sizes=\"(max-width: 620px) 100vw, 620px\" \/><p id=\"caption-attachment-16465\" class=\"wp-caption-text\">Pressing Button to Change Time Signature (4\/4, 2\/4, 6\/8)<\/p><\/div>\n<div id=\"attachment_16467\" style=\"width: 630px\" class=\"wp-caption aligncenter\"><img aria-describedby=\"caption-attachment-16467\" loading=\"lazy\" class=\"size-large wp-image-16467\" src=\"https:\/\/courses.ideate.cmu.edu\/60-223\/f2022\/work\/wp-content\/uploads\/2022\/10\/metronome-switching-to-speaker-819x1024.png\" alt=\"\" width=\"620\" height=\"775\" srcset=\"https:\/\/courses.ideate.cmu.edu\/60-223\/f2022\/work\/wp-content\/uploads\/2022\/10\/metronome-switching-to-speaker-819x1024.png 819w, https:\/\/courses.ideate.cmu.edu\/60-223\/f2022\/work\/wp-content\/uploads\/2022\/10\/metronome-switching-to-speaker-240x300.png 240w, https:\/\/courses.ideate.cmu.edu\/60-223\/f2022\/work\/wp-content\/uploads\/2022\/10\/metronome-switching-to-speaker-768x960.png 768w, https:\/\/courses.ideate.cmu.edu\/60-223\/f2022\/work\/wp-content\/uploads\/2022\/10\/metronome-switching-to-speaker-1229x1536.png 1229w, https:\/\/courses.ideate.cmu.edu\/60-223\/f2022\/work\/wp-content\/uploads\/2022\/10\/metronome-switching-to-speaker-1638x2048.png 1638w, https:\/\/courses.ideate.cmu.edu\/60-223\/f2022\/work\/wp-content\/uploads\/2022\/10\/metronome-switching-to-speaker-973x1216.png 973w, https:\/\/courses.ideate.cmu.edu\/60-223\/f2022\/work\/wp-content\/uploads\/2022\/10\/metronome-switching-to-speaker-508x635.png 508w\" sizes=\"(max-width: 620px) 100vw, 620px\" \/><p id=\"caption-attachment-16467\" class=\"wp-caption-text\">Switching Out Piezo Buzzer for Larger Speaker<\/p><\/div>\n<div id=\"attachment_16472\" style=\"width: 630px\" class=\"wp-caption aligncenter\"><img aria-describedby=\"caption-attachment-16472\" loading=\"lazy\" class=\"size-large wp-image-16472\" src=\"https:\/\/courses.ideate.cmu.edu\/60-223\/f2022\/work\/wp-content\/uploads\/2022\/10\/metronome-sketching-1024x768.png\" alt=\"\" width=\"620\" height=\"465\" srcset=\"https:\/\/courses.ideate.cmu.edu\/60-223\/f2022\/work\/wp-content\/uploads\/2022\/10\/metronome-sketching-1024x768.png 1024w, https:\/\/courses.ideate.cmu.edu\/60-223\/f2022\/work\/wp-content\/uploads\/2022\/10\/metronome-sketching-300x225.png 300w, https:\/\/courses.ideate.cmu.edu\/60-223\/f2022\/work\/wp-content\/uploads\/2022\/10\/metronome-sketching-768x576.png 768w, https:\/\/courses.ideate.cmu.edu\/60-223\/f2022\/work\/wp-content\/uploads\/2022\/10\/metronome-sketching-1536x1152.png 1536w, https:\/\/courses.ideate.cmu.edu\/60-223\/f2022\/work\/wp-content\/uploads\/2022\/10\/metronome-sketching-2048x1536.png 2048w, https:\/\/courses.ideate.cmu.edu\/60-223\/f2022\/work\/wp-content\/uploads\/2022\/10\/metronome-sketching-973x730.png 973w, https:\/\/courses.ideate.cmu.edu\/60-223\/f2022\/work\/wp-content\/uploads\/2022\/10\/metronome-sketching-508x381.png 508w\" sizes=\"(max-width: 620px) 100vw, 620px\" \/><p id=\"caption-attachment-16472\" class=\"wp-caption-text\">Moving from Usual Metronome Shape to Horizontal Design<\/p><\/div>\n<div style=\"width: 620px;\" class=\"wp-video\"><!--[if lt IE 9]><script>document.createElement('video');<\/script><![endif]-->\n<video class=\"wp-video-shortcode\" id=\"video-16442-1\" width=\"620\" height=\"349\" preload=\"metadata\" controls=\"controls\"><source type=\"video\/mp4\" src=\"https:\/\/courses.ideate.cmu.edu\/60-223\/f2022\/work\/wp-content\/uploads\/2022\/10\/IMG_3831.mp4?_=1\" \/><a href=\"https:\/\/courses.ideate.cmu.edu\/60-223\/f2022\/work\/wp-content\/uploads\/2022\/10\/IMG_3831.mp4\">https:\/\/courses.ideate.cmu.edu\/60-223\/f2022\/work\/wp-content\/uploads\/2022\/10\/IMG_3831.mp4<\/a><\/video><\/div>\n<h3 style=\"text-align: center\">Process<\/h3>\n<div id=\"attachment_16494\" style=\"width: 630px\" class=\"wp-caption aligncenter\"><img aria-describedby=\"caption-attachment-16494\" loading=\"lazy\" class=\"size-large wp-image-16494\" src=\"https:\/\/courses.ideate.cmu.edu\/60-223\/f2022\/work\/wp-content\/uploads\/2022\/10\/metronome-potentiometer-819x1024.png\" alt=\"\" width=\"620\" height=\"775\" srcset=\"https:\/\/courses.ideate.cmu.edu\/60-223\/f2022\/work\/wp-content\/uploads\/2022\/10\/metronome-potentiometer-819x1024.png 819w, https:\/\/courses.ideate.cmu.edu\/60-223\/f2022\/work\/wp-content\/uploads\/2022\/10\/metronome-potentiometer-240x300.png 240w, https:\/\/courses.ideate.cmu.edu\/60-223\/f2022\/work\/wp-content\/uploads\/2022\/10\/metronome-potentiometer-768x960.png 768w, https:\/\/courses.ideate.cmu.edu\/60-223\/f2022\/work\/wp-content\/uploads\/2022\/10\/metronome-potentiometer-1229x1536.png 1229w, https:\/\/courses.ideate.cmu.edu\/60-223\/f2022\/work\/wp-content\/uploads\/2022\/10\/metronome-potentiometer-1638x2048.png 1638w, https:\/\/courses.ideate.cmu.edu\/60-223\/f2022\/work\/wp-content\/uploads\/2022\/10\/metronome-potentiometer-973x1216.png 973w, https:\/\/courses.ideate.cmu.edu\/60-223\/f2022\/work\/wp-content\/uploads\/2022\/10\/metronome-potentiometer-508x635.png 508w\" sizes=\"(max-width: 620px) 100vw, 620px\" \/><p id=\"caption-attachment-16494\" class=\"wp-caption-text\">Using Potentiometer to Control Volume by Changing Resistance<\/p><\/div>\n<div id=\"attachment_16492\" style=\"width: 630px\" class=\"wp-caption aligncenter\"><img aria-describedby=\"caption-attachment-16492\" loading=\"lazy\" class=\"size-large wp-image-16492\" src=\"https:\/\/courses.ideate.cmu.edu\/60-223\/f2022\/work\/wp-content\/uploads\/2022\/10\/metronome-process-1-768x1024.png\" alt=\"\" width=\"620\" height=\"827\" srcset=\"https:\/\/courses.ideate.cmu.edu\/60-223\/f2022\/work\/wp-content\/uploads\/2022\/10\/metronome-process-1-768x1024.png 768w, https:\/\/courses.ideate.cmu.edu\/60-223\/f2022\/work\/wp-content\/uploads\/2022\/10\/metronome-process-1-225x300.png 225w, https:\/\/courses.ideate.cmu.edu\/60-223\/f2022\/work\/wp-content\/uploads\/2022\/10\/metronome-process-1-1152x1536.png 1152w, https:\/\/courses.ideate.cmu.edu\/60-223\/f2022\/work\/wp-content\/uploads\/2022\/10\/metronome-process-1-1536x2048.png 1536w, https:\/\/courses.ideate.cmu.edu\/60-223\/f2022\/work\/wp-content\/uploads\/2022\/10\/metronome-process-1-973x1297.png 973w, https:\/\/courses.ideate.cmu.edu\/60-223\/f2022\/work\/wp-content\/uploads\/2022\/10\/metronome-process-1-508x677.png 508w\" sizes=\"(max-width: 620px) 100vw, 620px\" \/><p id=\"caption-attachment-16492\" class=\"wp-caption-text\">Code Used to Control Speaker Using Volume Library (Eventually Changed to mills())<\/p><\/div>\n<div id=\"attachment_16493\" style=\"width: 630px\" class=\"wp-caption aligncenter\"><img aria-describedby=\"caption-attachment-16493\" loading=\"lazy\" class=\"size-large wp-image-16493\" src=\"https:\/\/courses.ideate.cmu.edu\/60-223\/f2022\/work\/wp-content\/uploads\/2022\/10\/metronome-process-2-1024x837.png\" alt=\"\" width=\"620\" height=\"507\" srcset=\"https:\/\/courses.ideate.cmu.edu\/60-223\/f2022\/work\/wp-content\/uploads\/2022\/10\/metronome-process-2-1024x837.png 1024w, https:\/\/courses.ideate.cmu.edu\/60-223\/f2022\/work\/wp-content\/uploads\/2022\/10\/metronome-process-2-300x245.png 300w, https:\/\/courses.ideate.cmu.edu\/60-223\/f2022\/work\/wp-content\/uploads\/2022\/10\/metronome-process-2-768x628.png 768w, https:\/\/courses.ideate.cmu.edu\/60-223\/f2022\/work\/wp-content\/uploads\/2022\/10\/metronome-process-2-1536x1256.png 1536w, https:\/\/courses.ideate.cmu.edu\/60-223\/f2022\/work\/wp-content\/uploads\/2022\/10\/metronome-process-2-2048x1675.png 2048w, https:\/\/courses.ideate.cmu.edu\/60-223\/f2022\/work\/wp-content\/uploads\/2022\/10\/metronome-process-2-973x796.png 973w, https:\/\/courses.ideate.cmu.edu\/60-223\/f2022\/work\/wp-content\/uploads\/2022\/10\/metronome-process-2-508x415.png 508w\" sizes=\"(max-width: 620px) 100vw, 620px\" \/><p id=\"caption-attachment-16493\" class=\"wp-caption-text\">Adding Potentiometer that Controls BPM<\/p><\/div>\n<h3 style=\"text-align: center\">Discussion<\/h3>\n<p><span style=\"font-weight: 400\">This project, though the idea of a metronome seems simple, posed problems along the way that required me to rework hardware and software many times throughout the project timeline. The constant reworking, though, allowed me to develop a project that I am ultimately proud of and will be using to <\/span><i><span style=\"font-weight: 400\">assist<\/span><\/i><span style=\"font-weight: 400\"> me in my piano practice sessions. The final critique, I think, reflected what I thought about the project myself &#8211; the sound was \u201ceasy on the ear,\u201d the design allowed for easy understanding, and the BPM and volume additions were helpful in making it more personalized than the metronome on my digital keyboard. However, I do agree with constructive comments I received &#8211; that I could add more time signatures (or even have the ability to input a desired one) and add phrases like \u201cadagio\u201d (slow tempo), though I believe the latter would be more complicated, as \u201cadagio\u201d has a range of BPM from 66 &#8211; 76, rather than a specific one. Ultimately, any simple idea has a world of possibilities to explore, and after critique, I will be adding some of their ideas as having more options becomes helpful. And though I am happy with the way it turned out, with the knowledge that I now have about coding after completing this project, I could make some small changes that would vastly improve the usability of the metronome. For example, the BPM was not reflected correctly on the LCD display and the piece didn\u2019t fully close due to the breadboard and Arduino, but by editing the code to reflect the actual BPM and not the wait value, and using a solder breadboard and a smaller Arduino, I can easily get the interior hardware to fit inside the case I designed and have the LCD reflect exactly what I want. This project really opened my eyes to all the different ways you can code or set up something to have the exact same result. For example, my potentiometer that controlled volume needed to be set up differently from the usual VCC, GND, and output pins and instead was connected to ground through the piezo buzzer. I also had the same realization while coding when I was able to produce noise through a speaker, but in order to create time signatures, I had to scrap all of my code and begin again using millis() to make sure everything worked together. This was a recurring theme in my project &#8211; reworking &#8211; but, in the end, it came together and, with a bit of editing code and soldering, will be a fixture on my keyboard that I will continue to use and develop beyond the end of this class.<\/span><\/p>\n<h3 style=\"text-align: center\">Functional Block Diagram and Schematic<\/h3>\n<p><img loading=\"lazy\" class=\"size-large wp-image-16603 aligncenter\" src=\"https:\/\/courses.ideate.cmu.edu\/60-223\/f2022\/work\/wp-content\/uploads\/2022\/10\/Screen-Shot-2022-10-27-at-12.14.47-AM-1024x686.png\" alt=\"\" width=\"620\" height=\"415\" srcset=\"https:\/\/courses.ideate.cmu.edu\/60-223\/f2022\/work\/wp-content\/uploads\/2022\/10\/Screen-Shot-2022-10-27-at-12.14.47-AM-1024x686.png 1024w, https:\/\/courses.ideate.cmu.edu\/60-223\/f2022\/work\/wp-content\/uploads\/2022\/10\/Screen-Shot-2022-10-27-at-12.14.47-AM-300x201.png 300w, https:\/\/courses.ideate.cmu.edu\/60-223\/f2022\/work\/wp-content\/uploads\/2022\/10\/Screen-Shot-2022-10-27-at-12.14.47-AM-768x515.png 768w, https:\/\/courses.ideate.cmu.edu\/60-223\/f2022\/work\/wp-content\/uploads\/2022\/10\/Screen-Shot-2022-10-27-at-12.14.47-AM-973x652.png 973w, https:\/\/courses.ideate.cmu.edu\/60-223\/f2022\/work\/wp-content\/uploads\/2022\/10\/Screen-Shot-2022-10-27-at-12.14.47-AM-508x340.png 508w, https:\/\/courses.ideate.cmu.edu\/60-223\/f2022\/work\/wp-content\/uploads\/2022\/10\/Screen-Shot-2022-10-27-at-12.14.47-AM.png 1152w\" sizes=\"(max-width: 620px) 100vw, 620px\" \/><\/p>\n<p><img loading=\"lazy\" class=\"size-large wp-image-16602 aligncenter\" src=\"https:\/\/courses.ideate.cmu.edu\/60-223\/f2022\/work\/wp-content\/uploads\/2022\/10\/Screen-Shot-2022-10-27-at-12.14.41-AM-1024x734.png\" alt=\"\" width=\"620\" height=\"444\" srcset=\"https:\/\/courses.ideate.cmu.edu\/60-223\/f2022\/work\/wp-content\/uploads\/2022\/10\/Screen-Shot-2022-10-27-at-12.14.41-AM-1024x734.png 1024w, https:\/\/courses.ideate.cmu.edu\/60-223\/f2022\/work\/wp-content\/uploads\/2022\/10\/Screen-Shot-2022-10-27-at-12.14.41-AM-300x215.png 300w, https:\/\/courses.ideate.cmu.edu\/60-223\/f2022\/work\/wp-content\/uploads\/2022\/10\/Screen-Shot-2022-10-27-at-12.14.41-AM-768x550.png 768w, https:\/\/courses.ideate.cmu.edu\/60-223\/f2022\/work\/wp-content\/uploads\/2022\/10\/Screen-Shot-2022-10-27-at-12.14.41-AM-973x697.png 973w, https:\/\/courses.ideate.cmu.edu\/60-223\/f2022\/work\/wp-content\/uploads\/2022\/10\/Screen-Shot-2022-10-27-at-12.14.41-AM-508x364.png 508w, https:\/\/courses.ideate.cmu.edu\/60-223\/f2022\/work\/wp-content\/uploads\/2022\/10\/Screen-Shot-2022-10-27-at-12.14.41-AM.png 1354w\" sizes=\"(max-width: 620px) 100vw, 620px\" \/><\/p>\n<h3 style=\"text-align: center\">Code<\/h3>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"c\">\/* Metronome\r\n *  \r\n * The following code works to create a metronome that controls BPM (beats per minute), volume, and time signature.\r\n * The time signature and BPM are displayed on an LCD Display.\r\n * The time signature begins at 2\/4. When the time signature button is pressed, time signature becomes 4\/4.\r\n * When pressed a third time, time signature becomes 6\/8. When pressed again, the time signature will \r\n * become 2\/4 and repeat again when button is pressed.\r\n * \r\n * Pin Mapping:\r\n * \r\n * Arduino Pin \/  Role   \/ Description\r\n *      A1        INPUT     Controls BPM     \r\n *      2         INPUT     Controls time signature\r\n *      6         INPUT     Turns metronome on or off\r\n *      11        OUTPUT    Controls speaker\r\n *      \r\n * Francesca Menendez, 2022 *\/\r\n\r\n\r\n#include &lt;Wire.h&gt;\r\n#include &lt;LiquidCrystal_I2C.h&gt;\r\nconst int SPEAKERPIN = 11; \/\r\nconst int TIMESIGPIN = 2;\r\nconst int ONOFFPIN = 6;\r\nint WAITPIN = A1;\r\nint wait = 500; \/* Gap between beats *\/\r\nunsigned long timeGoal = 0;\r\nunsigned long lastTime;\r\nunsigned long counter = 0;\r\nint state = 0; \/* State begins at 0 *\/\r\nbool on = false;\r\nint potVal = 0;\r\nint frequency = 500;\r\nLiquidCrystal_I2C screen(0x27, 16, 2);\r\n\r\nvoid setup() {\r\n\/* Sets Up Pins Used *\/\r\n  pinMode(SPEAKERPIN, OUTPUT);\r\n  pinMode(ONOFFPIN, INPUT);\r\n  pinMode(WAITPIN, INPUT);\r\n  pinMode(TIMESIGPIN, INPUT);\r\n\r\n\/* Setup for LCD Display *\/\r\n  Wire.begin();\r\n  screen.init();\r\n  screen.backlight();\r\n  screen.home();\r\n\r\n  Serial.begin(9600);\r\n}\r\n\r\nvoid loop() {\r\n  \/* Creates timer using millis() to then set up time signatures *\/\r\n  int timer = millis();\r\n  wait = map(wait, 0, 1023, 10, 2000);\r\n  wait = analogRead(WAITPIN);\r\n\r\n  if(digitalRead(ONOFFPIN)== HIGH) {\r\n\r\n\/* When time signature button is pressed, state increases *\/\r\n    if (digitalRead(TIMSIGPIN) == HIGH) {\r\n      state++;\r\n      delay(100);\r\n    }\r\n\r\n\/* Metronome begins at 2\/4 time signature *\/\r\n    if (state%3 == 0) {\r\n      if (counter % 2 == 0) {\r\n        frequency = 800;\r\n      }\r\n      else {\r\n        frequency = 500;\r\n      }\r\n    }\r\n\/* When time signature button is pressed, time signature becomes 4\/4 *\/\r\n    if (state%3 == 1) {\r\n      if (counter % 4 == 0) {\r\n        frequency = 800;\r\n      }\r\n      else {\r\n        frequency = 500;\r\n      }\r\n    }\r\n\/* When time signature is pressed a third time, time signature becomes 6\/8 *\/\r\n    if (state%3 == 2) {\r\n      if (counter % 6 == 0) {\r\n        frequency = 800;\r\n      }\r\n      else if (counter % 3 == 0) {\r\n        frequency = 400;\r\n      }\r\n      else {\r\n        frequency = 500;\r\n      }\r\n    }\r\n\r\n  if (millis() - lastTime &gt;= wait) {\r\n    tone(SPEAKERPIN, frequency, 100);\r\n    counter++;\r\n    lastTime = millis();\r\n  }\r\n  \r\n  \/* LCD updates every half of a second *\/\r\n  if(millis()%250 == 0 ) {\r\n    screen.clear();\r\n  }\r\n \r\n\/* Prints BPM and Time Signature to LCD Display *\/\r\n  if(1000 &lt; millis() - timer) { \r\n      screen.setCursor(0, 0);\r\n      screen.print(\"BPM:\");\r\n      screen.setCursor(4,0);\r\n      screen.print(wait);\r\n      screen.setCursor(0, 1);\r\n      if(state%3 == 0) {\r\n        screen.print(\"Time Sig: 2\/4\");\r\n      }\r\n      if(state%3 == 1) {\r\n        screen.print(\"Time Sig: 4\/4\");\r\n      }\r\n      if(state%3 == 2) {\r\n        screen.print(\"Time Sig: 6\/8\");\r\n      }\r\n      timer = millis();\r\n    }\r\n  }\r\n}\r\n<\/pre>\n","protected":false},"excerpt":{"rendered":"<p>This metronome functions as a musician\u2019s tool to easily control beats per minute, switch between time signatures, as well as adjust volume using buttons and potentiometers for a&#8230;<\/p>\n","protected":false},"author":234,"featured_media":16463,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":[],"categories":[89,1],"tags":[],"_links":{"self":[{"href":"https:\/\/courses.ideate.cmu.edu\/60-223\/f2022\/work\/wp-json\/wp\/v2\/posts\/16442"}],"collection":[{"href":"https:\/\/courses.ideate.cmu.edu\/60-223\/f2022\/work\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/courses.ideate.cmu.edu\/60-223\/f2022\/work\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/courses.ideate.cmu.edu\/60-223\/f2022\/work\/wp-json\/wp\/v2\/users\/234"}],"replies":[{"embeddable":true,"href":"https:\/\/courses.ideate.cmu.edu\/60-223\/f2022\/work\/wp-json\/wp\/v2\/comments?post=16442"}],"version-history":[{"count":13,"href":"https:\/\/courses.ideate.cmu.edu\/60-223\/f2022\/work\/wp-json\/wp\/v2\/posts\/16442\/revisions"}],"predecessor-version":[{"id":16613,"href":"https:\/\/courses.ideate.cmu.edu\/60-223\/f2022\/work\/wp-json\/wp\/v2\/posts\/16442\/revisions\/16613"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/courses.ideate.cmu.edu\/60-223\/f2022\/work\/wp-json\/wp\/v2\/media\/16463"}],"wp:attachment":[{"href":"https:\/\/courses.ideate.cmu.edu\/60-223\/f2022\/work\/wp-json\/wp\/v2\/media?parent=16442"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/courses.ideate.cmu.edu\/60-223\/f2022\/work\/wp-json\/wp\/v2\/categories?post=16442"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/courses.ideate.cmu.edu\/60-223\/f2022\/work\/wp-json\/wp\/v2\/tags?post=16442"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}