{"id":3027,"date":"2022-04-02T06:10:25","date_gmt":"2022-04-02T13:10:25","guid":{"rendered":"https:\/\/www.donluc.com\/?p=3027"},"modified":"2022-04-02T06:10:25","modified_gmt":"2022-04-02T13:10:25","slug":"project-22-synthesizer-theremin-mk02","status":"publish","type":"post","link":"https:\/\/www.donluc.com\/?p=3027","title":{"rendered":"Project #22: Synthesizer &#8211; Theremin &#8211; Mk02"},"content":{"rendered":"<div style=\"width: 720px;\" class=\"wp-video\"><video class=\"wp-video-shortcode\" id=\"video-3027-1\" width=\"720\" height=\"480\" preload=\"metadata\" controls=\"controls\"><source type=\"video\/mp4\" src=\"https:\/\/www.donluc.com\/wp-content\/uploads\/2022\/04\/DL2203Mk01W.mp4?_=1\" \/><a href=\"https:\/\/www.donluc.com\/wp-content\/uploads\/2022\/04\/DL2203Mk01W.mp4\">https:\/\/www.donluc.com\/wp-content\/uploads\/2022\/04\/DL2203Mk01W.mp4<\/a><\/video><\/div>\n<p>&#8212;&#8212;<\/p>\n<p>#DonLucElectronics #DonLuc #Synthesizer #Theremin #Arduino #ArduinoProMini #Project #Fritzing #Programming #Electronics #Microcontrollers #Consultant<\/p>\n<p>&#8212;&#8212;<\/p>\n<p><a href=\"https:\/\/www.donluc.com\/wp-content\/uploads\/2022\/04\/DL2203Mk01a.png\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/www.donluc.com\/wp-content\/uploads\/2022\/04\/DL2203Mk01a.png\" alt=\"Theremin\" width=\"720\" height=\"395\" class=\"alignnone size-full wp-image-3029\" srcset=\"https:\/\/www.donluc.com\/wp-content\/uploads\/2022\/04\/DL2203Mk01a.png 720w, https:\/\/www.donluc.com\/wp-content\/uploads\/2022\/04\/DL2203Mk01a-300x165.png 300w\" sizes=\"auto, (max-width: 720px) 100vw, 720px\" \/><\/a><\/p>\n<p>&#8212;&#8212;<\/p>\n<p><a href=\"https:\/\/www.donluc.com\/wp-content\/uploads\/2022\/04\/DL2203Mk01b.png\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/www.donluc.com\/wp-content\/uploads\/2022\/04\/DL2203Mk01b.png\" alt=\"Theremin\" width=\"720\" height=\"480\" class=\"alignnone size-full wp-image-3030\" srcset=\"https:\/\/www.donluc.com\/wp-content\/uploads\/2022\/04\/DL2203Mk01b.png 720w, https:\/\/www.donluc.com\/wp-content\/uploads\/2022\/04\/DL2203Mk01b-300x200.png 300w\" sizes=\"auto, (max-width: 720px) 100vw, 720px\" \/><\/a><\/p>\n<p>&#8212;&#8212;<\/p>\n<p><a href=\"https:\/\/www.donluc.com\/wp-content\/uploads\/2022\/04\/DL2203Mk01c.png\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/www.donluc.com\/wp-content\/uploads\/2022\/04\/DL2203Mk01c.png\" alt=\"Theremin\" width=\"720\" height=\"480\" class=\"alignnone size-full wp-image-3031\" srcset=\"https:\/\/www.donluc.com\/wp-content\/uploads\/2022\/04\/DL2203Mk01c.png 720w, https:\/\/www.donluc.com\/wp-content\/uploads\/2022\/04\/DL2203Mk01c-300x200.png 300w\" sizes=\"auto, (max-width: 720px) 100vw, 720px\" \/><\/a><\/p>\n<p>&#8212;&#8212;<\/p>\n<p><strong>Theremin<\/strong><\/p>\n<p>The theremin was invented in 1920 by a Russian physicist named Lev Termen. Today, this marvelous instrument is once again in the musical spotlight. Besides looking like no other instrument, the theremin is unique in that it is played without being touched. <\/p>\n<p>Two antennas protrude from the theremin, one controlling pitch, and the other controlling volume. As a hand approaches the vertical antenna, the pitch gets higher. Approaching the horizontal antenna makes the volume softer. Because there is no physical contact with the instrument, playing the theremin in a precise melodic way requires practiced skill and keen attention to pitch. The electric signals from the theremin are amplified and sent to a loudspeaker.<\/p>\n<p>In the late 1920&#8217;s, RCA produced approximately 500 theremins, manufactured by General Electric and Westinghouse. Today, it is estimated that only half of these still exist. The spooky sound of the theremin was used in several movie soundtracks during the 1950&#8217;s and 1960&#8217;s. Electronic music pioneer Robert Moog built theremins long before he built synthesizers. In the 1960&#8217;s, he produced such models as the wedge-shaped Vanguard theremin and the shoebox shaped Moog Melodia theremin. It provided background mood music for such sci-fi classics. During the 60&#8217;s and 70&#8217;s, bands such as Lothar and the Hand People, the Bonzo Doo Dah Dog Band, and Led Zeppelin brought the theremin into the public eye for a short time.<\/p>\n<p><strong>Theremin + Arduino Pro Mini + Ultrasonic Sensor + Mozzi<\/strong><\/p>\n<p>Arduino Pro Mini does not come with connectors populated so that you can solder in any connector or wire with any orientation you need. This is the ultrasonic distance sensor. This economical sensor provides 2cm to 400cm of non-contact measurement functionality. The ultrasonic range detectors replace the antenna of the traditional Theremin. Control the frequency (pitch) of the output. Operation of the sensor is straightforward. The Arduino sends a digital pulse to the TRIG pin of the sensor causing it to emit a burst of high frequency audio. If an echo is detected the sensor toggles the ECHO pin which is monitored by the Arduino. By measuring the time delay between the outgoing pulse and returning echo we can calculate the distance. As sound takes 29 microseconds to travel one cm, and must travel out and back, we can divide the time to the echo by 5.8 to get the distance in mm. The project uses the Mozzi audio library to generate a sine table for oscillator which is sent to the output.<\/p>\n<p><strong>DL2203Mk01<\/strong><\/p>\n<p>1 x Arduino Pro Mini 328 &#8211; 5V\/16MHz<br \/>\n1 x SparkFun FTDI Basic Breakout &#8211; 5V<br \/>\n1 x HC-SR04 Ultrasonic Sensor<br \/>\n1 x Audio Jack 3.5mm<br \/>\n1 x SparkFun Audio Jack Breakout<br \/>\n1 x Hamburger Mini Speaker<br \/>\n1 x Full-Size Breadboard<br \/>\n1 x SparkFun Cerberus USB Cable<\/p>\n<p><strong>Arduino Pro Mini 328 &#8211; 5V\/16MHz &#8211; Receiver<\/strong><\/p>\n<p>Ech &#8211; Digital 13<br \/>\nTri &#8211; Digital 12<br \/>\nSPK &#8211; Digital 9<br \/>\nVIN &#8211; +5V<br \/>\nGND &#8211; GND<\/p>\n<p><strong>DL2203Mk01p.ino<\/strong><\/p>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"arduino\" data-enlighter-title=\"\">\r\n\/* ***** Don Luc Electronics \u00a9 *****\r\nSoftware Version Information\r\nProject #22: Synthesizer - Theremin - Mk02\r\n22-02\r\nDL2203Mk01p.ino\r\n1 x Arduino Pro Mini 328 - 5V\/16MHz\r\n1 x SparkFun FTDI Basic Breakout - 5V\r\n1 x HC-SR04 Ultrasonic Sensor\r\n1 x Audio Jack 3.5mm\r\n1 x SparkFun Audio Jack Breakout\r\n1 x Hamburger Mini Speaker\r\n1 x Full-Size Breadboard\r\n1 x SparkFun Cerberus USB Cable\r\n*\/\r\n\r\n\/\/ Include the Library Code\r\n\/\/ Mozzi\r\n#include &lt;MozziGuts.h&gt;\r\n\/\/ Oscillator template\r\n#include &lt;Oscil.h&gt;\r\n\/\/ Sine table for oscillator\r\n#include &lt;tables\/sin2048_int8.h&gt;\r\n\/\/ Rolling Average\r\n#include &lt;RollingAverage.h&gt;\r\n\/\/ Control Delay\r\n#include &lt;ControlDelay.h&gt;\r\n\r\n\/\/ Control Rate\r\n#define CONTROL_RATE 64\r\n\/\/ Echo Cells\r\nunsigned int echo_cells_1 = 32;\r\nunsigned int echo_cells_2 = 60;\r\nunsigned int echo_cells_3 = 127;\r\n\/\/ Contro lDelay = 2 seconds\r\nControlDelay &lt;128, int&gt; kDelay; \r\n\/\/ Oscils to compare bumpy to averaged control input\r\nOscil &lt;SIN2048_NUM_CELLS, AUDIO_RATE&gt; aSin0(SIN2048_DATA);\r\nOscil &lt;SIN2048_NUM_CELLS, AUDIO_RATE&gt; aSin1(SIN2048_DATA);\r\nOscil &lt;SIN2048_NUM_CELLS, AUDIO_RATE&gt; aSin2(SIN2048_DATA);\r\nOscil &lt;SIN2048_NUM_CELLS, AUDIO_RATE&gt; aSin3(SIN2048_DATA);\r\n\/\/ RollingAverage &lt;number_type, how_many_to_average&gt; myThing\r\n\/\/ How many to average has to be power of 2\r\nRollingAverage &lt;int, 32&gt; kAverage;\r\nint averaged;\r\n\r\n\/\/ Trigger pin 12 to pitch distance sensor\r\nconst int iTrigPitch = 12;\r\n\/\/ Echo Receive pin 13 to pitch distance sensor\r\nconst int iEchoPitch = 13;\r\n\/\/ Stores the distance measured by the distance sensor\r\nfloat distance = 0;\r\n\r\n\/\/ Mini Speaker\r\nint SPK = 9;\r\n\r\n\/\/ Set the input for the volume\r\n\/\/ Volume level from updateControl() to updateAudio()\r\nbyte vol;\r\n\r\n\/\/ Software Version Information\r\nString sver = &quot;22-02&quot;;\r\n\r\nvoid loop() {\r\n\r\n  \/\/ Audio Hook\r\n  audioHook();\r\n  \r\n}\r\n<\/pre>\n<p><strong>getHC-SR04.ino<\/strong><\/p>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"arduino\" data-enlighter-title=\"\">\r\n\/\/ HC-SR04 Ultrasonic Sensor\r\n\/\/ Setup HC-SR04\r\nvoid setupHCSR04() {\r\n\r\n  \/\/ The trigger iTrig will output pulses of electricity\r\n  pinMode(iTrigPitch, OUTPUT);\r\n  \/\/ The echo iEcho will measure the duration of pulses coming back from the distance sensor\r\n  pinMode(iEchoPitch, INPUT);\r\n  \r\n}\r\n\/\/ Distance\r\nfloat isDistance() {\r\n  \r\n  \/\/ Variable to store the time it takes for a ping to bounce off an object\r\n  float echoTime;\r\n  \/\/ Variable to store the distance calculated from the echo time\r\n  float calculatedDistance;\r\n\r\n  \/\/ Send out an ultrasonic pulse that&#039;s 10ms long\r\n  digitalWrite(iTrigPitch, HIGH);\r\n  delayMicroseconds(10);\r\n  digitalWrite(iTrigPitch, LOW);\r\n\r\n  \/\/ Use the pulseIn command to see how long it takes for the\r\n  \/\/ pulse to bounce back to the sensor\r\n  echoTime = pulseIn(iEchoPitch, HIGH);\r\n\r\n  \/\/ Calculate the distance of the object that reflected the pulse\r\n  \/\/ (half the bounce time multiplied by the speed of sound)\r\n  \/\/ cm = 58.0\r\n  calculatedDistance = echoTime \/ 58.0;\r\n\r\n  \/\/ Send back the distance that was calculated\r\n  return calculatedDistance;\r\n  \r\n}\r\n<\/pre>\n<p><strong>getMozzi.ino<\/strong><\/p>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"arduino\" data-enlighter-title=\"\">\r\n\/\/ Mozzi\r\n\/\/ Update Control\r\nvoid updateControl(){\r\n\r\n  \/\/ Volume\r\n  vol = 255;\r\n  \/\/ Variable to store the distance measured by the sensor\r\n  distance = isDistance();\r\n  int bumpy_input = distance;\r\n  \/\/ Averaged\r\n  averaged = kAverage.next(bumpy_input);\r\n  aSin0.setFreq(averaged);\r\n  aSin1.setFreq(kDelay.next(averaged));\r\n  aSin2.setFreq(kDelay.read(echo_cells_2));\r\n  aSin3.setFreq(kDelay.read(echo_cells_3));\r\n\r\n}\r\n\/\/ Update Audio\r\nint updateAudio()\r\n{\r\n\r\n  \/\/ Update Audio\r\n  return 3*((int)aSin0.next()+aSin1.next()+(aSin2.next()&gt;&gt;1)\r\n    +(aSin3.next()&gt;&gt;2)) &gt;&gt;3;\r\n\r\n}\r\n<\/pre>\n<p><strong>setup.ino<\/strong><\/p>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"arduino\" data-enlighter-title=\"\">\r\n\/\/ Setup\r\nvoid setup() {\r\n\r\n  \/\/ Setup HC-SR04\r\n  setupHCSR04();\r\n\r\n  \/\/ Echo Cells 1\r\n  kDelay.set(echo_cells_1);\r\n\r\n  \/\/ Mozzi Start\r\n  startMozzi();\r\n\r\n}\r\n<\/pre>\n<p>&#8212;&#8212;<\/p>\n<p><strong>People can contact us:<\/strong> https:\/\/www.donluc.com\/?page_id=1927<\/p>\n<p><strong>Technology Experience<\/strong><\/p>\n<ul>\n<li>Single-Board Microcontrollers (PIC, Arduino, Raspberry Pi,Espressif, etc&#8230;)<\/li>\n<li>IoT<\/li>\n<li>Robotics<\/li>\n<li>Camera and Video Capture Receiver Stationary, Wheel\/Tank and Underwater Vehicle<\/li>\n<li>Unmanned Vehicles Terrestrial and Marine<\/li>\n<li>Research &#038; Development (R &#038; D)<\/li>\n<li>Desktop Applications (Windows, OSX, Linux, Multi-OS, Multi-Tier, etc&#8230;)<\/li>\n<li>Mobile Applications (Android, iOS, Blackberry, Windows Mobile, Windows CE, etc&#8230;)<\/li>\n<li>Web Applications (LAMP, Scripting, Java, ASP, ASP.NET, RoR, Wakanda, etc&#8230;)<\/li>\n<li>Social Media Programming &#038; Integration (Facebook, Twitter, YouTube, Pinterest, etc&#8230;)<\/li>\n<li>Content Management Systems (WordPress, Drupal, Joomla, Moodle, etc&#8230;)<\/li>\n<li>Bulletin Boards (phpBB, SMF, Vanilla, jobberBase, etc&#8230;)<\/li>\n<li>eCommerce (WooCommerce, OSCommerce, ZenCart, PayPal Shopping Cart, etc&#8230;)<\/li>\n<\/ul>\n<p><strong>Instructor and E-Mentor<\/strong><\/p>\n<ul>\n<li>IoT<\/li>\n<li>PIC Microcontrollers<\/li>\n<li>Arduino<\/li>\n<li>Raspberry Pi<\/li>\n<li>Espressif<\/li>\n<li>Robotics<\/li>\n<li>DOS, Windows, OSX, Linux, iOS, Android, Multi-OS<\/li>\n<li>Linux-Apache-PHP-MySQL<\/li>\n<\/ul>\n<p><strong>Follow Us<\/strong><\/p>\n<p><strong>J. Luc Paquin \u2013 Curriculum Vitae &#8211; 2022 English &#038; Espa\u00f1ol<\/strong><br \/>\nhttps:\/\/www.jlpconsultants.com\/luc\/<\/p>\n<p><strong>Web:<\/strong> https:\/\/www.donluc.com\/<br \/>\n<strong>Web:<\/strong> https:\/\/www.jlpconsultants.com\/<br \/>\n<strong>Facebook:<\/strong> https:\/\/www.facebook.com\/neosteam.labs.9\/<br \/>\n<strong>YouTube:<\/strong> https:\/\/www.youtube.com\/channel\/UC5eRjrGn1CqkkGfZy0jxEdA<br \/>\n<strong>Twitter:<\/strong> https:\/\/twitter.com\/labs_steam<br \/>\n<strong>Pinterest:<\/strong> https:\/\/www.pinterest.com\/NeoSteamLabs\/<br \/>\n<strong>Instagram:<\/strong> https:\/\/www.instagram.com\/neosteamlabs\/<\/p>\n<p><strong>Don Luc<\/strong><\/p>\n","protected":false},"excerpt":{"rendered":"<p>&#8212;&#8212; #DonLucElectronics #DonLuc #Synthesizer #Theremin #Arduino #ArduinoProMini #Project #Fritzing #Programming #Electronics #Microcontrollers #Consultant &#8212;&#8212; &#8212;&#8212; &#8212;&#8212; &#8212;&#8212; Theremin The theremin was invented in 1920 by a Russian physicist named Lev Termen. Today, this marvelous instrument is once again in the musical spotlight. Besides looking like no other instrument, the theremin is unique in that it &#8230; <a title=\"Project #22: Synthesizer &#8211; Theremin &#8211; Mk02\" class=\"read-more\" href=\"https:\/\/www.donluc.com\/?p=3027\" aria-label=\"Read more about Project #22: Synthesizer &#8211; Theremin &#8211; Mk02\">Read more<\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[205,50,38,59,5,7,58,10,43,51],"tags":[6,102,4,19,85,24,25,9,27,109,8,127,33,214,34],"class_list":["post-3027","post","type-post","status-publish","format-standard","hentry","category-synthesizer","category-arduino","category-digitalelectronics","category-fritzing","category-microcontrollers","category-musical-instruments","category-arduino-programming","category-projects","category-sparkfun","category-synth","tag-arduino","tag-components","tag-consultant","tag-electronics","tag-fritzing","tag-microcontroller","tag-musical-instruments-2","tag-programming","tag-projects-2","tag-sparkfun","tag-synth","tag-synthesizer","tag-technology","tag-theremin","tag-video-blog"],"_links":{"self":[{"href":"https:\/\/www.donluc.com\/index.php?rest_route=\/wp\/v2\/posts\/3027","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.donluc.com\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.donluc.com\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.donluc.com\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.donluc.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=3027"}],"version-history":[{"count":2,"href":"https:\/\/www.donluc.com\/index.php?rest_route=\/wp\/v2\/posts\/3027\/revisions"}],"predecessor-version":[{"id":3989,"href":"https:\/\/www.donluc.com\/index.php?rest_route=\/wp\/v2\/posts\/3027\/revisions\/3989"}],"wp:attachment":[{"href":"https:\/\/www.donluc.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=3027"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.donluc.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=3027"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.donluc.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=3027"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}