{"id":919,"date":"2014-06-12T12:21:51","date_gmt":"2014-06-12T19:21:51","guid":{"rendered":"https:\/\/blog.digilentinc.com\/?p=919"},"modified":"2021-06-17T08:56:18","modified_gmt":"2021-06-17T15:56:18","slug":"making-your-own-metronome","status":"publish","type":"post","link":"https:\/\/digilent.com\/blog\/making-your-own-metronome\/","title":{"rendered":"Making Your Own Metronome"},"content":{"rendered":"<p>Microcontrollers can be utilized in a wide variety of applications, including musical applications. \u00a0In keeping with this theme, I&#8217;m\u00a0going to take a look today at how to\u00a0create my\u00a0own adjustable metronome\u00a0using Digilent&#8217;s <a href=\"https:\/\/digilent.com\/blog\/Products\/Detail.cfm?NavPath=2,892,1233&amp;Prod=CHIPKIT-STARTERKIT\" target=\"_blank\" rel=\"noopener\">chipKIT&#x2122; Starter Kit<\/a>.<\/p>\n<p>&nbsp;<\/p>\n<p>The primary visual piece of the metronome is the servo motor. \u00a0For those of you who aren&#8217;t\u00a0familiar with servo motors, they are a type of motor that has precise control over where the servo arm is rotated. \u00a0This is in contrast to a DC motor, which does not have precise control over the amount of rotation but can spin much much faster than servo motors. \u00a0Our particular servo motor, an SG92R micro servo, is able to rotate between 0 and 180 degree angles.\u00a0This is perfect for a metronome.<\/p>\n<p><a href=\"https:\/\/digilent.com\/blog\/wp-content\/uploads\/2014\/06\/SG92R-servo-motor.jpg\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter wp-image-920 \" src=\"https:\/\/digilent.com\/blog\/wp-content\/uploads\/2014\/06\/SG92R-servo-motor-1024x768.jpg\" alt=\"SG92R servo motor\" width=\"600\" height=\"450\" srcset=\"https:\/\/digilent.com\/blog\/wp-content\/uploads\/2014\/06\/SG92R-servo-motor-1024x768.jpg 1024w, https:\/\/digilent.com\/blog\/wp-content\/uploads\/2014\/06\/SG92R-servo-motor-300x225.jpg 300w, https:\/\/digilent.com\/blog\/wp-content\/uploads\/2014\/06\/SG92R-servo-motor-600x450.jpg 600w, https:\/\/digilent.com\/blog\/wp-content\/uploads\/2014\/06\/SG92R-servo-motor-800x600.jpg 800w, https:\/\/digilent.com\/blog\/wp-content\/uploads\/2014\/06\/SG92R-servo-motor-1200x900-cropped.jpg 1200w\" sizes=\"auto, (max-width: 600px) 100vw, 600px\" \/><\/a><\/p>\n<p>A potentiometer controls\u00a0how fast the metronome is moving. But exactly how fast (or slow) can it\u00a0go? According to the <a href=\"http:\/\/www.towerpro.com.tw\/viewitem1.asp?sn=737&amp;area=50&amp;cat=159\" target=\"_blank\" rel=\"noopener\">TowerPro website<\/a>,\u00a0the fastest that the servo arm can move is 60 degrees every 0.1 seconds. \u00a0Keeping in mind that a &#8220;beat&#8221; occurs at every 0 or 180 degree angle, and after a bit of math, we can see that this is gives us a maximum tempo of 200 beats-per-minute (bpm), which is a pretty solid pace.<\/p>\n<p>&nbsp;<\/p>\n<p>Before we get into how slow our metronome can go, I want to clarify\u00a0how this works. \u00a0We won&#8217;t \u00a0physically slow down the servo arm; that&#8217;ll always keep going at the 60 degrees\/ 0.1 second pace (at least in our setup). \u00a0What we will be doing\u00a0is telling the servo arm to move a smaller distance that it is otherwise capable of moving. \u00a0This means that if we tell the servo arm to only move 30 degrees in 0.1 seconds, it will get to its destination in 0.05 seconds and then wait for another command\u00a0for the remaining 0.05 seconds. \u00a0If we give the servo small enough time intervals, this phenomenon will give the appearance that\u00a0the metronome is moving slower when it really is just stopping and starting a lot.<\/p>\n<p>&nbsp;<\/p>\n<p>That being said, we could, in theory, have the metronome go as slow as we want it to. \u00a0But after talking to some more musically inclined friends, I decided to make the slowest tempo be 50 bpm. \u00a0This is slower than a ticking clock, so any slower would mean you most likely writing a dirge for your own funeral, which I imagine would not be terribly fun. Hence the lower limit\u00a0of 50 bpm.<\/p>\n<p>&nbsp;<\/p>\n<figure id=\"attachment_5054\" aria-describedby=\"caption-attachment-5054\" style=\"width: 600px\" class=\"wp-caption aligncenter\"><a href=\"https:\/\/digilent.com\/blog\/wp-content\/uploads\/2014\/06\/Piezoelectric-Speaker.jpg\"><img loading=\"lazy\" decoding=\"async\" class=\" wp-image-5054\" src=\"https:\/\/digilent.com\/blog\/wp-content\/uploads\/2014\/06\/Piezoelectric-Speaker.jpg\" alt=\"Piezoelectric Speaker from the chipKIT Starter Kit.\" width=\"600\" height=\"500\" srcset=\"https:\/\/digilent.com\/blog\/wp-content\/uploads\/2014\/06\/Piezoelectric-Speaker.jpg 1201w, https:\/\/digilent.com\/blog\/wp-content\/uploads\/2014\/06\/Piezoelectric-Speaker-600x500.jpg 600w, https:\/\/digilent.com\/blog\/wp-content\/uploads\/2014\/06\/Piezoelectric-Speaker-1024x853.jpg 1024w, https:\/\/digilent.com\/blog\/wp-content\/uploads\/2014\/06\/Piezoelectric-Speaker-225x188.jpg 225w\" sizes=\"auto, (max-width: 600px) 100vw, 600px\" \/><\/a><figcaption id=\"caption-attachment-5054\" class=\"wp-caption-text\">Piezoelectric Speaker from the chipKIT Starter Kit.<\/figcaption><\/figure>\n<p>The speaker buzzer is what will create the traditional &#8220;tick&#8221; that is associated with metronomes. \u00a0Speaker buzzers work\u00a0because of the piezoelectric element inside of them. Piezoelectric elements are a\u00a0type of material that changes its shape when an electric current is applied (or conversely for some piezoelectrics, \u00a0produce an electric current when pressure is applied).<\/p>\n<p>&nbsp;<\/p>\n<p>This phenomenon can be taken advantage of by turning the current to the speaker buzzer on and off at various rates to make the element in the buzzer vibrate and thus produce sounds of different frequencies. \u00a0You could even make some <a title=\"Music with a Piezoeelectric Buzzer Learn Module\" href=\"https:\/\/learn.blog.digilentinc.com\/Documents\/392\" target=\"_blank\" rel=\"noopener\">music with a speaker buzzer<\/a>! \u00a0However, we do not want to have the servo motor visibly stopping while the speaker is buzzing at every 0\u00a0and 180 degree mark, so we will end up only allowing enough time for the speaker to produce an audible\u00a0&#8220;click&#8221;, which is more appropriate for a metronome anyway.<\/p>\n<p>&nbsp;<\/p>\n<p>Finally, we can use the <a href=\"https:\/\/digilent.com\/blog\/Products\/Detail.cfm?NavPath=2,892,936&amp;Prod=CHIPKIT-BASIC-IO-SHIELD\" target=\"_blank\" rel=\"noopener\">chipKIT Basic I\/O Shield<\/a> to display what the current bpm of our metronome is operating at. \u00a0Check out the demo video for a closer look of the metronome in action.<\/p>\n<p>&nbsp;<\/p>\n<p><iframe loading=\"lazy\" width=\"735\" height=\"413\" src=\"https:\/\/www.youtube.com\/embed\/90PMaYcN5tQ?feature=oembed\" frameborder=\"0\" allow=\"autoplay; encrypted-media\" allowfullscreen><\/iframe><\/p>\n<div class='watch-action'><div class='watch-position align-left'><div class='action-like'><a class='lbg-style6 like-919 jlk' data-task='like' data-post_id='919' data-nonce='e5335d04d0' rel='nofollow'><img src='https:\/\/digilent.com\/blog\/wp-content\/plugins\/wti-like-post-pro\/images\/pixel.gif' title='Like' \/><span class='lc-919 lc'>0<\/span><\/a><\/div><div class='action-unlike'><a class='unlbg-style6 unlike-919 jlk' data-task='unlike' data-post_id='919' data-nonce='e5335d04d0' rel='nofollow'><img src='https:\/\/digilent.com\/blog\/wp-content\/plugins\/wti-like-post-pro\/images\/pixel.gif' title='Unlike' \/><span class='unlc-919 unlc'>0<\/span><\/a><\/div><\/div> <div class='status-919 status align-left'>Be the 1st to vote.<\/div><\/div><div class='wti-clear'><\/div>","protected":false},"excerpt":{"rendered":"<p>Microcontrollers can be utilized in a wide variety of applications, including musical applications. \u00a0In keeping with this theme, I&#8217;m\u00a0going to take a look today at how to\u00a0create my\u00a0own adjustable metronome\u00a0using &hellip; <\/p>\n","protected":false},"author":17,"featured_media":920,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[18,20,4327],"tags":[104],"ppma_author":[4469],"class_list":["post-919","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-academia","category-products","category-projects","tag-project-2"],"jetpack_featured_media_url":"https:\/\/digilent.com\/blog\/wp-content\/uploads\/2014\/06\/SG92R-servo-motor.jpg","authors":[{"term_id":4469,"user_id":17,"is_guest":0,"slug":"jamescolvin","display_name":"James Colvin","avatar_url":"https:\/\/secure.gravatar.com\/avatar\/509febded809c5de0423909f6ae6587f?s=96&d=mm&r=g","author_category":"","user_url":"","last_name":"Colvin","last_name_2":"","first_name":"James","first_name_2":"","job_title":"Applications Engineer \/ Technical Support Engineer \/ Product Support Engineer \/ Technical Writer \/ the person to bother about T&M and JTAG when the senior design engineer is busy","description":"A local Digilent employee who is sometimes tricked into making other content besides documentation and supporting customers on the Digilent Forum, but then I get to write a little more informally so that's a plus. \r\n\r\nA sassy engineer, lover of puns and dad jokes, father and husband. \r\n\r\nI know both way too much and simultaneously almost nothing about a number of nerdy topics. If you want to hear me rant, ask me what data rate USB C operates at."}],"post_mailing_queue_ids":[],"_links":{"self":[{"href":"https:\/\/digilent.com\/blog\/wp-json\/wp\/v2\/posts\/919","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/digilent.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/digilent.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/digilent.com\/blog\/wp-json\/wp\/v2\/users\/17"}],"replies":[{"embeddable":true,"href":"https:\/\/digilent.com\/blog\/wp-json\/wp\/v2\/comments?post=919"}],"version-history":[{"count":0,"href":"https:\/\/digilent.com\/blog\/wp-json\/wp\/v2\/posts\/919\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/digilent.com\/blog\/wp-json\/wp\/v2\/media\/920"}],"wp:attachment":[{"href":"https:\/\/digilent.com\/blog\/wp-json\/wp\/v2\/media?parent=919"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/digilent.com\/blog\/wp-json\/wp\/v2\/categories?post=919"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/digilent.com\/blog\/wp-json\/wp\/v2\/tags?post=919"},{"taxonomy":"author","embeddable":true,"href":"https:\/\/digilent.com\/blog\/wp-json\/wp\/v2\/ppma_author?post=919"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}