{"id":15316,"date":"2022-03-16T01:38:48","date_gmt":"2022-03-16T05:38:48","guid":{"rendered":"https:\/\/courses.ideate.cmu.edu\/60-223\/s2022\/work\/?p=15316"},"modified":"2022-03-16T01:43:11","modified_gmt":"2022-03-16T05:43:11","slug":"music-composer-helper","status":"publish","type":"post","link":"https:\/\/courses.ideate.cmu.edu\/60-223\/s2022\/work\/music-composer-helper\/","title":{"rendered":"Music Composer Helper"},"content":{"rendered":"<p>This is a choker that can start recording autonomously when it detects the user humming unconsciously in the bathroom.<\/p>\n<div id=\"attachment_15336\" style=\"width: 2570px\" class=\"wp-caption alignnone\"><img aria-describedby=\"caption-attachment-15336\" loading=\"lazy\" class=\"size-full wp-image-15336\" src=\"https:\/\/courses.ideate.cmu.edu\/60-223\/s2022\/work\/wp-content\/uploads\/2022\/03\/IMG_193220220315-034428-scaled.jpg\" alt=\"\" width=\"2560\" height=\"1585\" srcset=\"https:\/\/courses.ideate.cmu.edu\/60-223\/s2022\/work\/wp-content\/uploads\/2022\/03\/IMG_193220220315-034428-scaled.jpg 2560w, https:\/\/courses.ideate.cmu.edu\/60-223\/s2022\/work\/wp-content\/uploads\/2022\/03\/IMG_193220220315-034428-300x186.jpg 300w, https:\/\/courses.ideate.cmu.edu\/60-223\/s2022\/work\/wp-content\/uploads\/2022\/03\/IMG_193220220315-034428-1024x634.jpg 1024w, https:\/\/courses.ideate.cmu.edu\/60-223\/s2022\/work\/wp-content\/uploads\/2022\/03\/IMG_193220220315-034428-768x476.jpg 768w, https:\/\/courses.ideate.cmu.edu\/60-223\/s2022\/work\/wp-content\/uploads\/2022\/03\/IMG_193220220315-034428-1536x951.jpg 1536w, https:\/\/courses.ideate.cmu.edu\/60-223\/s2022\/work\/wp-content\/uploads\/2022\/03\/IMG_193220220315-034428-2048x1268.jpg 2048w, https:\/\/courses.ideate.cmu.edu\/60-223\/s2022\/work\/wp-content\/uploads\/2022\/03\/IMG_193220220315-034428-973x602.jpg 973w, https:\/\/courses.ideate.cmu.edu\/60-223\/s2022\/work\/wp-content\/uploads\/2022\/03\/IMG_193220220315-034428-508x315.jpg 508w\" sizes=\"(max-width: 2560px) 100vw, 2560px\" \/><p id=\"caption-attachment-15336\" class=\"wp-caption-text\">The choker compared to a quarter dollar coin<\/p><\/div>\n<div id=\"attachment_15337\" style=\"width: 2562px\" class=\"wp-caption alignnone\"><img aria-describedby=\"caption-attachment-15337\" loading=\"lazy\" class=\"size-full wp-image-15337\" src=\"https:\/\/courses.ideate.cmu.edu\/60-223\/s2022\/work\/wp-content\/uploads\/2022\/03\/IMG_1928.jpg\" alt=\"\" width=\"2552\" height=\"1675\" srcset=\"https:\/\/courses.ideate.cmu.edu\/60-223\/s2022\/work\/wp-content\/uploads\/2022\/03\/IMG_1928.jpg 2552w, https:\/\/courses.ideate.cmu.edu\/60-223\/s2022\/work\/wp-content\/uploads\/2022\/03\/IMG_1928-300x197.jpg 300w, https:\/\/courses.ideate.cmu.edu\/60-223\/s2022\/work\/wp-content\/uploads\/2022\/03\/IMG_1928-1024x672.jpg 1024w, https:\/\/courses.ideate.cmu.edu\/60-223\/s2022\/work\/wp-content\/uploads\/2022\/03\/IMG_1928-768x504.jpg 768w, https:\/\/courses.ideate.cmu.edu\/60-223\/s2022\/work\/wp-content\/uploads\/2022\/03\/IMG_1928-1536x1008.jpg 1536w, https:\/\/courses.ideate.cmu.edu\/60-223\/s2022\/work\/wp-content\/uploads\/2022\/03\/IMG_1928-2048x1344.jpg 2048w, https:\/\/courses.ideate.cmu.edu\/60-223\/s2022\/work\/wp-content\/uploads\/2022\/03\/IMG_1928-973x639.jpg 973w, https:\/\/courses.ideate.cmu.edu\/60-223\/s2022\/work\/wp-content\/uploads\/2022\/03\/IMG_1928-508x333.jpg 508w\" sizes=\"(max-width: 2552px) 100vw, 2552px\" \/><p id=\"caption-attachment-15337\" class=\"wp-caption-text\">The front look of the choker<\/p><\/div>\n<div id=\"attachment_15338\" style=\"width: 2570px\" class=\"wp-caption alignnone\"><img aria-describedby=\"caption-attachment-15338\" loading=\"lazy\" class=\"size-full wp-image-15338\" src=\"https:\/\/courses.ideate.cmu.edu\/60-223\/s2022\/work\/wp-content\/uploads\/2022\/03\/IMG_1929-scaled.jpg\" alt=\"\" width=\"2560\" height=\"1465\" srcset=\"https:\/\/courses.ideate.cmu.edu\/60-223\/s2022\/work\/wp-content\/uploads\/2022\/03\/IMG_1929-scaled.jpg 2560w, https:\/\/courses.ideate.cmu.edu\/60-223\/s2022\/work\/wp-content\/uploads\/2022\/03\/IMG_1929-300x172.jpg 300w, https:\/\/courses.ideate.cmu.edu\/60-223\/s2022\/work\/wp-content\/uploads\/2022\/03\/IMG_1929-1024x586.jpg 1024w, https:\/\/courses.ideate.cmu.edu\/60-223\/s2022\/work\/wp-content\/uploads\/2022\/03\/IMG_1929-768x439.jpg 768w, https:\/\/courses.ideate.cmu.edu\/60-223\/s2022\/work\/wp-content\/uploads\/2022\/03\/IMG_1929-1536x879.jpg 1536w, https:\/\/courses.ideate.cmu.edu\/60-223\/s2022\/work\/wp-content\/uploads\/2022\/03\/IMG_1929-2048x1172.jpg 2048w, https:\/\/courses.ideate.cmu.edu\/60-223\/s2022\/work\/wp-content\/uploads\/2022\/03\/IMG_1929-973x557.jpg 973w, https:\/\/courses.ideate.cmu.edu\/60-223\/s2022\/work\/wp-content\/uploads\/2022\/03\/IMG_1929-508x291.jpg 508w\" sizes=\"(max-width: 2560px) 100vw, 2560px\" \/><p id=\"caption-attachment-15338\" class=\"wp-caption-text\">The piezo that detects the vibration on the neck and the microphone that detects and records sound<\/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-15316-1\" width=\"620\" height=\"349\" preload=\"metadata\" controls=\"controls\"><source type=\"video\/mp4\" src=\"https:\/\/courses.ideate.cmu.edu\/60-223\/s2022\/work\/wp-content\/uploads\/2022\/03\/notrecord.mp4?_=1\" \/><a href=\"https:\/\/courses.ideate.cmu.edu\/60-223\/s2022\/work\/wp-content\/uploads\/2022\/03\/notrecord.mp4\">https:\/\/courses.ideate.cmu.edu\/60-223\/s2022\/work\/wp-content\/uploads\/2022\/03\/notrecord.mp4<\/a><\/video><\/div>\n<div id=\"attachment_15341\" style=\"width: 2570px\" class=\"wp-caption alignnone\"><img aria-describedby=\"caption-attachment-15341\" loading=\"lazy\" class=\"size-full wp-image-15341\" src=\"https:\/\/courses.ideate.cmu.edu\/60-223\/s2022\/work\/wp-content\/uploads\/2022\/03\/IMG_1806-scaled.jpg\" alt=\"\" width=\"2560\" height=\"1920\" srcset=\"https:\/\/courses.ideate.cmu.edu\/60-223\/s2022\/work\/wp-content\/uploads\/2022\/03\/IMG_1806-scaled.jpg 2560w, https:\/\/courses.ideate.cmu.edu\/60-223\/s2022\/work\/wp-content\/uploads\/2022\/03\/IMG_1806-300x225.jpg 300w, https:\/\/courses.ideate.cmu.edu\/60-223\/s2022\/work\/wp-content\/uploads\/2022\/03\/IMG_1806-1024x768.jpg 1024w, https:\/\/courses.ideate.cmu.edu\/60-223\/s2022\/work\/wp-content\/uploads\/2022\/03\/IMG_1806-768x576.jpg 768w, https:\/\/courses.ideate.cmu.edu\/60-223\/s2022\/work\/wp-content\/uploads\/2022\/03\/IMG_1806-1536x1152.jpg 1536w, https:\/\/courses.ideate.cmu.edu\/60-223\/s2022\/work\/wp-content\/uploads\/2022\/03\/IMG_1806-2048x1536.jpg 2048w, https:\/\/courses.ideate.cmu.edu\/60-223\/s2022\/work\/wp-content\/uploads\/2022\/03\/IMG_1806-973x730.jpg 973w, https:\/\/courses.ideate.cmu.edu\/60-223\/s2022\/work\/wp-content\/uploads\/2022\/03\/IMG_1806-508x381.jpg 508w\" sizes=\"(max-width: 2560px) 100vw, 2560px\" \/><p id=\"caption-attachment-15341\" class=\"wp-caption-text\">The choker doesn&#8217;t begin recording until the sound volume and the level of vibration both reach the thresholds<\/p><\/div>\n<div id=\"attachment_15342\" style=\"width: 2570px\" class=\"wp-caption alignnone\"><img aria-describedby=\"caption-attachment-15342\" loading=\"lazy\" class=\"size-full wp-image-15342\" src=\"https:\/\/courses.ideate.cmu.edu\/60-223\/s2022\/work\/wp-content\/uploads\/2022\/03\/IMG_1804-scaled.jpg\" alt=\"\" width=\"2560\" height=\"1920\" srcset=\"https:\/\/courses.ideate.cmu.edu\/60-223\/s2022\/work\/wp-content\/uploads\/2022\/03\/IMG_1804-scaled.jpg 2560w, https:\/\/courses.ideate.cmu.edu\/60-223\/s2022\/work\/wp-content\/uploads\/2022\/03\/IMG_1804-300x225.jpg 300w, https:\/\/courses.ideate.cmu.edu\/60-223\/s2022\/work\/wp-content\/uploads\/2022\/03\/IMG_1804-1024x768.jpg 1024w, https:\/\/courses.ideate.cmu.edu\/60-223\/s2022\/work\/wp-content\/uploads\/2022\/03\/IMG_1804-768x576.jpg 768w, https:\/\/courses.ideate.cmu.edu\/60-223\/s2022\/work\/wp-content\/uploads\/2022\/03\/IMG_1804-1536x1152.jpg 1536w, https:\/\/courses.ideate.cmu.edu\/60-223\/s2022\/work\/wp-content\/uploads\/2022\/03\/IMG_1804-2048x1536.jpg 2048w, https:\/\/courses.ideate.cmu.edu\/60-223\/s2022\/work\/wp-content\/uploads\/2022\/03\/IMG_1804-973x730.jpg 973w, https:\/\/courses.ideate.cmu.edu\/60-223\/s2022\/work\/wp-content\/uploads\/2022\/03\/IMG_1804-508x381.jpg 508w\" sizes=\"(max-width: 2560px) 100vw, 2560px\" \/><p id=\"caption-attachment-15342\" class=\"wp-caption-text\">The audios will be saved to the SD card<\/p><\/div>\n<p><strong>Process<\/strong><\/p>\n<p>The first change I recorded is the choice of vibration detector, I was using a vibration sensor with a digital output at first, and it turned out that it cannot detect small vibration on the neck very well, then I changed it into a piezo.<\/p>\n<div id=\"attachment_15349\" style=\"width: 1584px\" class=\"wp-caption alignnone\"><img aria-describedby=\"caption-attachment-15349\" loading=\"lazy\" class=\"size-full wp-image-15349\" src=\"https:\/\/courses.ideate.cmu.edu\/60-223\/s2022\/work\/wp-content\/uploads\/2022\/03\/circled.jpg\" alt=\"\" width=\"1574\" height=\"2100\" srcset=\"https:\/\/courses.ideate.cmu.edu\/60-223\/s2022\/work\/wp-content\/uploads\/2022\/03\/circled.jpg 1574w, https:\/\/courses.ideate.cmu.edu\/60-223\/s2022\/work\/wp-content\/uploads\/2022\/03\/circled-225x300.jpg 225w, https:\/\/courses.ideate.cmu.edu\/60-223\/s2022\/work\/wp-content\/uploads\/2022\/03\/circled-768x1025.jpg 768w, https:\/\/courses.ideate.cmu.edu\/60-223\/s2022\/work\/wp-content\/uploads\/2022\/03\/circled-1151x1536.jpg 1151w, https:\/\/courses.ideate.cmu.edu\/60-223\/s2022\/work\/wp-content\/uploads\/2022\/03\/circled-1535x2048.jpg 1535w, https:\/\/courses.ideate.cmu.edu\/60-223\/s2022\/work\/wp-content\/uploads\/2022\/03\/circled-973x1298.jpg 973w, https:\/\/courses.ideate.cmu.edu\/60-223\/s2022\/work\/wp-content\/uploads\/2022\/03\/circled-508x678.jpg 508w\" sizes=\"(max-width: 1574px) 100vw, 1574px\" \/><p id=\"caption-attachment-15349\" class=\"wp-caption-text\">The circled device is the vibration sensor I was originally using<\/p><\/div>\n<p>The second change is the overall appearance of the choker, I was thinking about only leaving the Arduino Nano outside, but in the end I flipped it over to make the choker more flexible to wear.<\/p>\n<div id=\"attachment_15350\" style=\"width: 1930px\" class=\"wp-caption alignnone\"><img aria-describedby=\"caption-attachment-15350\" loading=\"lazy\" class=\"size-full wp-image-15350\" src=\"https:\/\/courses.ideate.cmu.edu\/60-223\/s2022\/work\/wp-content\/uploads\/2022\/03\/choker-front-scaled.jpg\" alt=\"\" width=\"1920\" height=\"2560\" srcset=\"https:\/\/courses.ideate.cmu.edu\/60-223\/s2022\/work\/wp-content\/uploads\/2022\/03\/choker-front-scaled.jpg 1920w, https:\/\/courses.ideate.cmu.edu\/60-223\/s2022\/work\/wp-content\/uploads\/2022\/03\/choker-front-225x300.jpg 225w, https:\/\/courses.ideate.cmu.edu\/60-223\/s2022\/work\/wp-content\/uploads\/2022\/03\/choker-front-768x1024.jpg 768w, https:\/\/courses.ideate.cmu.edu\/60-223\/s2022\/work\/wp-content\/uploads\/2022\/03\/choker-front-1152x1536.jpg 1152w, https:\/\/courses.ideate.cmu.edu\/60-223\/s2022\/work\/wp-content\/uploads\/2022\/03\/choker-front-1536x2048.jpg 1536w, https:\/\/courses.ideate.cmu.edu\/60-223\/s2022\/work\/wp-content\/uploads\/2022\/03\/choker-front-973x1297.jpg 973w, https:\/\/courses.ideate.cmu.edu\/60-223\/s2022\/work\/wp-content\/uploads\/2022\/03\/choker-front-508x677.jpg 508w\" sizes=\"(max-width: 1920px) 100vw, 1920px\" \/><p id=\"caption-attachment-15350\" class=\"wp-caption-text\">The original design &#8211; outside<\/p><\/div>\n<div id=\"attachment_15351\" style=\"width: 2570px\" class=\"wp-caption alignnone\"><img aria-describedby=\"caption-attachment-15351\" loading=\"lazy\" class=\"size-full wp-image-15351\" src=\"https:\/\/courses.ideate.cmu.edu\/60-223\/s2022\/work\/wp-content\/uploads\/2022\/03\/chokerbackfoam-scaled.jpg\" alt=\"\" width=\"2560\" height=\"1920\" srcset=\"https:\/\/courses.ideate.cmu.edu\/60-223\/s2022\/work\/wp-content\/uploads\/2022\/03\/chokerbackfoam-scaled.jpg 2560w, https:\/\/courses.ideate.cmu.edu\/60-223\/s2022\/work\/wp-content\/uploads\/2022\/03\/chokerbackfoam-300x225.jpg 300w, https:\/\/courses.ideate.cmu.edu\/60-223\/s2022\/work\/wp-content\/uploads\/2022\/03\/chokerbackfoam-1024x768.jpg 1024w, https:\/\/courses.ideate.cmu.edu\/60-223\/s2022\/work\/wp-content\/uploads\/2022\/03\/chokerbackfoam-768x576.jpg 768w, https:\/\/courses.ideate.cmu.edu\/60-223\/s2022\/work\/wp-content\/uploads\/2022\/03\/chokerbackfoam-1536x1152.jpg 1536w, https:\/\/courses.ideate.cmu.edu\/60-223\/s2022\/work\/wp-content\/uploads\/2022\/03\/chokerbackfoam-2048x1536.jpg 2048w, https:\/\/courses.ideate.cmu.edu\/60-223\/s2022\/work\/wp-content\/uploads\/2022\/03\/chokerbackfoam-973x730.jpg 973w, https:\/\/courses.ideate.cmu.edu\/60-223\/s2022\/work\/wp-content\/uploads\/2022\/03\/chokerbackfoam-508x381.jpg 508w\" sizes=\"(max-width: 2560px) 100vw, 2560px\" \/><p id=\"caption-attachment-15351\" class=\"wp-caption-text\">The origin design &#8211; inside<\/p><\/div>\n<div id=\"attachment_15354\" style=\"width: 1930px\" class=\"wp-caption alignnone\"><img aria-describedby=\"caption-attachment-15354\" loading=\"lazy\" class=\"size-full wp-image-15354\" src=\"https:\/\/courses.ideate.cmu.edu\/60-223\/s2022\/work\/wp-content\/uploads\/2022\/03\/IMG_1925-scaled.jpg\" alt=\"\" width=\"1920\" height=\"2560\" srcset=\"https:\/\/courses.ideate.cmu.edu\/60-223\/s2022\/work\/wp-content\/uploads\/2022\/03\/IMG_1925-scaled.jpg 1920w, https:\/\/courses.ideate.cmu.edu\/60-223\/s2022\/work\/wp-content\/uploads\/2022\/03\/IMG_1925-225x300.jpg 225w, https:\/\/courses.ideate.cmu.edu\/60-223\/s2022\/work\/wp-content\/uploads\/2022\/03\/IMG_1925-768x1024.jpg 768w, https:\/\/courses.ideate.cmu.edu\/60-223\/s2022\/work\/wp-content\/uploads\/2022\/03\/IMG_1925-1152x1536.jpg 1152w, https:\/\/courses.ideate.cmu.edu\/60-223\/s2022\/work\/wp-content\/uploads\/2022\/03\/IMG_1925-1536x2048.jpg 1536w, https:\/\/courses.ideate.cmu.edu\/60-223\/s2022\/work\/wp-content\/uploads\/2022\/03\/IMG_1925-973x1297.jpg 973w, https:\/\/courses.ideate.cmu.edu\/60-223\/s2022\/work\/wp-content\/uploads\/2022\/03\/IMG_1925-508x677.jpg 508w\" sizes=\"(max-width: 1920px) 100vw, 1920px\" \/><p id=\"caption-attachment-15354\" class=\"wp-caption-text\">I flipped it over so that it&#8217;s really flexible and comfortable to wear<\/p><\/div>\n<p>There are also changes in code that I forgot to record, I was using a na\u00efve for loop calculating the average value to reduce noise but it didn&#8217;t work very well, later I use a Kalman filter instead.<\/p>\n<p><strong>Discussion<\/strong><\/p>\n<p>There are several comments regarding the appearance of the choker, some people are saying &#8220;<span style=\"font-weight: 400\">the Arduino Nano as a &#8216;jewel\u2019 is pretty neat looking, very high tech esthetic&#8221;, there are also people suggesting &#8220;hide the electronic board in the choker&#8221; or &#8220;hide all the electronics beneath some crystal\/stone decor&#8221;. There are also comments regarding the user experience, people are saying &#8220;Softening the wires against your neck&#8221; and &#8220;Assembly and build is challenging to make robust and comfortable&#8221;. In the end, the choker turns out to be super cyberpunk due to me trying to make it comfortable to wear given limited hardware. Cyberpunk fans may like it while fans of traditional aesthetics may hate it. We don&#8217;t have wires in the lab that are soft enough, and the design of the SD card module make the choker super uncomfortable to wear if I attach the module to the choker. In fact, the original design is already a compromise, my idea is actually to make it into a modern silicon choker where the electronic components are all hidden in it, but due to limitations, this is how the final product looks like.<\/span><\/p>\n<p>I&#8217;m personally not very satisfied about this project, because it doesn&#8217;t look very stable and I actually ran into an uploading issue when I finally decided to upload the code to Arduino Nano. There are some issues in the code as well, and I still cannot figure that out. A lot more extra work is needed in order to make it really satisfy me.<\/p>\n<p>What I learned from this project is that it&#8217;s hard to deal with unfamiliar hardware and software libraries, my life would be much easier if I don&#8217;t try so many weird stuff. My original thought was just beyond the scope of this course, that&#8217;s not something I can finish using limited materials in such limited time. Apart from the hardware part, I was originally also thinking about writing code to make the choker actually distinguish between humming and other sound. I wanted to make something really useful that no other things can achieve the same result. My advice to my past self would be: don&#8217;t be too ambitious, why not just make a calorie tracker? You can definitely track it on your phone but it&#8217;s still a good little thing to have.<\/p>\n<p>If I have chance to build another iteration of this project, I will debug the software first, and also acquire necessary materials to build a safe, stable, and good-looking choker. I will try to use Bluetooth instead of using SD card, and I will write code for distinguishing between music sound and noise.<\/p>\n<p><strong>Block Diagram<\/strong><\/p>\n<p><img loading=\"lazy\" class=\"alignnone size-full wp-image-15429\" src=\"https:\/\/courses.ideate.cmu.edu\/60-223\/s2022\/work\/wp-content\/uploads\/2022\/03\/music-composer-helper-functional.jpg\" alt=\"\" width=\"787\" height=\"281\" srcset=\"https:\/\/courses.ideate.cmu.edu\/60-223\/s2022\/work\/wp-content\/uploads\/2022\/03\/music-composer-helper-functional.jpg 787w, https:\/\/courses.ideate.cmu.edu\/60-223\/s2022\/work\/wp-content\/uploads\/2022\/03\/music-composer-helper-functional-300x107.jpg 300w, https:\/\/courses.ideate.cmu.edu\/60-223\/s2022\/work\/wp-content\/uploads\/2022\/03\/music-composer-helper-functional-768x274.jpg 768w, https:\/\/courses.ideate.cmu.edu\/60-223\/s2022\/work\/wp-content\/uploads\/2022\/03\/music-composer-helper-functional-508x181.jpg 508w\" sizes=\"(max-width: 787px) 100vw, 787px\" \/><\/p>\n<p><strong>Schematic Diagram<\/strong><\/p>\n<p><img loading=\"lazy\" class=\"alignnone size-full wp-image-15438\" src=\"https:\/\/courses.ideate.cmu.edu\/60-223\/s2022\/work\/wp-content\/uploads\/2022\/03\/music-composer-helper-schematic.jpg\" alt=\"\" width=\"991\" height=\"623\" srcset=\"https:\/\/courses.ideate.cmu.edu\/60-223\/s2022\/work\/wp-content\/uploads\/2022\/03\/music-composer-helper-schematic.jpg 991w, https:\/\/courses.ideate.cmu.edu\/60-223\/s2022\/work\/wp-content\/uploads\/2022\/03\/music-composer-helper-schematic-300x189.jpg 300w, https:\/\/courses.ideate.cmu.edu\/60-223\/s2022\/work\/wp-content\/uploads\/2022\/03\/music-composer-helper-schematic-768x483.jpg 768w, https:\/\/courses.ideate.cmu.edu\/60-223\/s2022\/work\/wp-content\/uploads\/2022\/03\/music-composer-helper-schematic-973x612.jpg 973w, https:\/\/courses.ideate.cmu.edu\/60-223\/s2022\/work\/wp-content\/uploads\/2022\/03\/music-composer-helper-schematic-508x319.jpg 508w\" sizes=\"(max-width: 991px) 100vw, 991px\" \/><\/p>\n<p><strong>Code<\/strong><\/p>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"c\">\/*\r\n  Music Composer Helper\r\n  This code enables the choker to record for 3 minutes when the volume and \r\n  vibration reach their thresholds, and save the audio to the SD card.\r\n*\/\r\n\/*\r\n  Hardware Pinout Connection\r\n  Arduino Nano\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0SD Pin\r\n       5V ------------ VCC\r\n       GND ----------- GND\r\n       D10 ----------- CS\r\n       D11 ----------- MOSI\r\n       D12 ----------- MISO\r\n       D13 ----------- SCK\r\n________________________________________\r\n  Arduino Nano\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0Microphone\r\n       5v ------------- VCC\r\n       GND ------------ GND\r\n       A0 ------------- Out\r\n________________________________________\r\n  Arduino Nano\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 Piezo\r\n       GND ---------- negative\r\n       A5 ----------- positive\r\n*\/\r\n\/*\r\n  credit\r\n  https:\/\/circuitdigest.com\/microcontroller-projects\/simple-arduino-voice-\r\n  recorder-for-spy-bug-voice-recording\r\n*\/\r\n#include &lt;SimpleKalmanFilter.h&gt;\r\n#include &lt;TMRpcm.h&gt;\/\/the library for recording\r\n#include &lt;SD.h&gt;\r\n#include &lt;SPI.h&gt;\r\n#define SD_CSPin 10\r\n#define vib_pin A5\r\n#define mic_pin A0;\r\nconst int sample_rate = 16000;\r\nint file_number = 0;\r\nint vib = 0;\r\nint vol = 0;\r\nunsigned int sample;\r\nfloat estimated_vol = 0;\r\nfloat estimated_vib = 0;\r\nchar filePrefixname[50] = \"rec\";\r\nchar exten[10] = \".wav\";\r\nTMRpcm audio;\r\n\/*\r\n  SimpleKalmanFilter(e_mea, e_est, q);\r\n  e_mea: Measurement Uncertainty\r\n  e_est: Estimation Uncertainty\r\n  q: Process Noise\r\n*\/\r\nSimpleKalmanFilter volumeKalmanFilter(1, 1, 0.01);\r\nSimpleKalmanFilter vibrationKalmanFilter(1, 1, 0.01);\r\n\/\/ delay function for serial log.\r\nvoid wait_min(int mins) {\r\n  int count = 0;\r\n  int secs = mins * 60;\r\n  while (1) {\r\n    Serial.print('.');\r\n    delay(1000);\r\n    count++;\r\n    if (count == secs) {\r\n      count = 0;\r\n      break;\r\n    }\r\n  }\r\n  Serial.println();\r\n  return ;\r\n}\r\nvoid setup() {\r\n  Serial.begin(9600);\r\n  \/\/Sets up the pins\r\n  pinMode(mic_pin, INPUT);\r\n  pinMode(vib_pin, INPUT);\r\n  \/\/Checking SD card\r\n  Serial.println(\"loading... SD card\");\r\n  if (!SD.begin(SD_CSPin)) {\r\n    Serial.println(\"An Error has occurred while mounting SD\");\r\n  }\r\n  while (!SD.begin(SD_CSPin)) {\r\n    Serial.print(\".\");\r\n    delay(500);\r\n  }\r\n  audio.CSPin = SD_CSPin;\r\n}\r\n\r\nvoid loop() {\r\n  \/\/print volume\r\n  vol = analogRead(mic_pin);\r\n  estimated_vol = volumeKalmanFilter.updateEstimate(vol);\r\n  Serial.print(\"vol \");\r\n  Serial.println(estimated_vol);\r\n  \/\/print vibration\r\n  vib = analogRead(vib_pin);\r\n  estimated_vib = vibrationKalmanFilter.updateEstimate(vib);\r\n  Serial.print(\"vib \");\r\n  Serial.println(estimated_vib);\r\n  \/\/print file name\r\n  char fileSlNum[20] = \"\";\r\n  itoa(file_number, fileSlNum, 10);\r\n  char file_name[50] = \"\";\r\n  strcat(file_name, filePrefixname);\r\n  strcat(file_name, fileSlNum);\r\n  strcat(file_name, exten);\r\n  Serial.print(\"New File Name: \");\r\n  Serial.println(file_name);\r\n  \/\/record if volume and vibration hit thresholds\r\n  if (estimated_vol &gt; 510 &amp;&amp; estimated_vib &gt; 1) {\r\n    audio.startRecording(file_name, sample_rate, mic_pin);\r\n    vol=0;\r\n    vib=0;\r\n    estimated_vol = 0;\r\n    estimated_vib = 0;\r\n    Serial.println(\"startRecording \");\r\n    \/\/ record audio for 3mins\r\n    wait_min(3);\r\n    audio.stopRecording(file_name);\r\n    Serial.println(\"stopRecording\");\r\n    file_number++;\r\n  }\r\n  \/\/clear values to avoid bugs\r\n  vol=0;\r\n  vib=0;\r\n  estimated_vol = 0;\r\n  estimated_vib = 0;\r\n}<\/pre>\n<p>&nbsp;<\/p>\n","protected":false},"excerpt":{"rendered":"<p>This is a choker that can start recording autonomously when it detects the user humming unconsciously in the bathroom. Process The first change I recorded is the choice&#8230;<\/p>\n","protected":false},"author":208,"featured_media":15317,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":[],"categories":[89],"tags":[],"_links":{"self":[{"href":"https:\/\/courses.ideate.cmu.edu\/60-223\/s2022\/work\/wp-json\/wp\/v2\/posts\/15316"}],"collection":[{"href":"https:\/\/courses.ideate.cmu.edu\/60-223\/s2022\/work\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/courses.ideate.cmu.edu\/60-223\/s2022\/work\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/courses.ideate.cmu.edu\/60-223\/s2022\/work\/wp-json\/wp\/v2\/users\/208"}],"replies":[{"embeddable":true,"href":"https:\/\/courses.ideate.cmu.edu\/60-223\/s2022\/work\/wp-json\/wp\/v2\/comments?post=15316"}],"version-history":[{"count":6,"href":"https:\/\/courses.ideate.cmu.edu\/60-223\/s2022\/work\/wp-json\/wp\/v2\/posts\/15316\/revisions"}],"predecessor-version":[{"id":15590,"href":"https:\/\/courses.ideate.cmu.edu\/60-223\/s2022\/work\/wp-json\/wp\/v2\/posts\/15316\/revisions\/15590"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/courses.ideate.cmu.edu\/60-223\/s2022\/work\/wp-json\/wp\/v2\/media\/15317"}],"wp:attachment":[{"href":"https:\/\/courses.ideate.cmu.edu\/60-223\/s2022\/work\/wp-json\/wp\/v2\/media?parent=15316"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/courses.ideate.cmu.edu\/60-223\/s2022\/work\/wp-json\/wp\/v2\/categories?post=15316"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/courses.ideate.cmu.edu\/60-223\/s2022\/work\/wp-json\/wp\/v2\/tags?post=15316"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}