{"id":1143,"date":"2011-12-18T17:36:47","date_gmt":"2011-12-18T17:36:47","guid":{"rendered":"http:\/\/www.collab.scrapyardchallenge.com\/?p=1143"},"modified":"2011-12-18T18:48:36","modified_gmt":"2011-12-18T18:48:36","slug":"final-project-the-grammoshield","status":"publish","type":"post","link":"http:\/\/www.collab.scrapyardchallenge.com\/?p=1143","title":{"rendered":"Final Project &#8211; The Grammoshield"},"content":{"rendered":"<p>I was lucky enough to win a bet with a friend (something about the melting temperature of a plastic..) and got his superb grammaphone. Here&#8217;s what i wanted to do : i will place a woofer inside of the grammaphone&#8217;s horn, and connect it to an amplifier, an arduino and a computer. It will basically be a &#8220;remake&#8221; of the grammaphone or &#8220;a new version&#8221; of it. The role of the arduino is to be connected to the LoL Shield, which will be reacting to the sound waves, it will displayed an audio spectrum. That will not be the only option, i also want to use the &#8220;crank&#8221;, basically triggering an energy or something when the platform is moving.<\/p>\n<p>This is what i ended up doing : on the mechanical wheels of the gramophone, i saw there was a little space between the biggest wheel and the wood. I thought this would be a good place to install a pressure sensor which would trigger something. Therefore i decided to install the pressure sensor under that wheel and stick some velcro on the wheel itself so that a pressure is applied on the sensor every half lap. The reason for the pressure sensor location is that it can be triggered by cranking the handle. Therefore all the user needs to do is cranking the handle, as on any gramophones, and the mechanism (from analog to digital) will run by itself.<\/p>\n<p>When pressure is applied onto the pressure sensor (which is connected to the breadboard inside the gramophone box), it is detected on processing as values. I used a code that sends bytes from arduino to processing (serial event) so that i could use a sound library on processing : MINIM. What i asked arduino is to detect values when pressure is applied. What i asked processing is to detect that arduino detected values. When it detects that, those bytes are sent to processing and when the value is superior to 1, play a music (player.play) otherwise, pause it (player.pause). At the same time, i have a LOL (Lots of Leds) shield acting as an audio spectrum and reacting as sound waves to the beats and frequencies of the sound. So every time sound is detected, the LoL shield reacts as an audio spectrum, otherwise, it stops. To have the music played from the computer to the amplifier to the woofer, i obvisouly needed an audio jack. If i wanted the LoL Shield to work at the same time, i&#8217;d need another one. So what i did is that i installed a double audio jacks receiver on the amplifier so i can plug both the sound and the LoL shield. Only problem with this is that i&#8217;m loosing a bit of the quality of the sound; but the horn of the gramophone amplifies the sound by itself.<\/p>\n<p><strong>HERE IS THE VIDEO :<\/strong> <a title=\"The Grammoshield\" href=\"http:\/\/vimeo.com\/33864489\" target=\"_blank\">http:\/\/vimeo.com\/33864489<\/a><\/p>\n<p>&nbsp;<\/p>\n<p><a href=\"http:\/\/www.collab.scrapyardchallenge.com\/wp-content\/uploads\/2011\/12\/IMG_5227.jpg\"><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-medium wp-image-1149\" src=\"http:\/\/www.collab.scrapyardchallenge.com\/wp-content\/uploads\/2011\/12\/IMG_5227-300x200.jpg\" alt=\"\" width=\"300\" height=\"200\" srcset=\"http:\/\/www.collab.scrapyardchallenge.com\/wp-content\/uploads\/2011\/12\/IMG_5227-300x200.jpg 300w, http:\/\/www.collab.scrapyardchallenge.com\/wp-content\/uploads\/2011\/12\/IMG_5227-1024x682.jpg 1024w\" sizes=\"auto, (max-width: 300px) 100vw, 300px\" \/><\/a><a href=\"http:\/\/www.collab.scrapyardchallenge.com\/wp-content\/uploads\/2011\/12\/IMG_5228.jpg\"><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-medium wp-image-1150\" src=\"http:\/\/www.collab.scrapyardchallenge.com\/wp-content\/uploads\/2011\/12\/IMG_5228-300x200.jpg\" alt=\"\" width=\"300\" height=\"200\" srcset=\"http:\/\/www.collab.scrapyardchallenge.com\/wp-content\/uploads\/2011\/12\/IMG_5228-300x200.jpg 300w, http:\/\/www.collab.scrapyardchallenge.com\/wp-content\/uploads\/2011\/12\/IMG_5228-1024x682.jpg 1024w\" sizes=\"auto, (max-width: 300px) 100vw, 300px\" \/><\/a><a href=\"http:\/\/www.collab.scrapyardchallenge.com\/wp-content\/uploads\/2011\/12\/IMG_5229.jpg\"><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-medium wp-image-1151\" src=\"http:\/\/www.collab.scrapyardchallenge.com\/wp-content\/uploads\/2011\/12\/IMG_5229-300x200.jpg\" alt=\"\" width=\"300\" height=\"200\" srcset=\"http:\/\/www.collab.scrapyardchallenge.com\/wp-content\/uploads\/2011\/12\/IMG_5229-300x200.jpg 300w, http:\/\/www.collab.scrapyardchallenge.com\/wp-content\/uploads\/2011\/12\/IMG_5229-1024x682.jpg 1024w\" sizes=\"auto, (max-width: 300px) 100vw, 300px\" \/><\/a><\/p>\n<p><a href=\"http:\/\/www.collab.scrapyardchallenge.com\/wp-content\/uploads\/2011\/12\/IMG_5230.jpg\"><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-medium wp-image-1152\" src=\"http:\/\/www.collab.scrapyardchallenge.com\/wp-content\/uploads\/2011\/12\/IMG_5230-300x200.jpg\" alt=\"\" width=\"300\" height=\"200\" srcset=\"http:\/\/www.collab.scrapyardchallenge.com\/wp-content\/uploads\/2011\/12\/IMG_5230-300x200.jpg 300w, http:\/\/www.collab.scrapyardchallenge.com\/wp-content\/uploads\/2011\/12\/IMG_5230-1024x682.jpg 1024w\" sizes=\"auto, (max-width: 300px) 100vw, 300px\" \/><\/a><a href=\"http:\/\/www.collab.scrapyardchallenge.com\/wp-content\/uploads\/2011\/12\/IMG_5232.jpg\"><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-medium wp-image-1153\" src=\"http:\/\/www.collab.scrapyardchallenge.com\/wp-content\/uploads\/2011\/12\/IMG_5232-300x200.jpg\" alt=\"\" width=\"300\" height=\"200\" srcset=\"http:\/\/www.collab.scrapyardchallenge.com\/wp-content\/uploads\/2011\/12\/IMG_5232-300x200.jpg 300w, http:\/\/www.collab.scrapyardchallenge.com\/wp-content\/uploads\/2011\/12\/IMG_5232-1024x682.jpg 1024w\" sizes=\"auto, (max-width: 300px) 100vw, 300px\" \/><\/a><a href=\"http:\/\/www.collab.scrapyardchallenge.com\/wp-content\/uploads\/2011\/12\/IMG_5235.jpg\"><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-medium wp-image-1155\" src=\"http:\/\/www.collab.scrapyardchallenge.com\/wp-content\/uploads\/2011\/12\/IMG_5235-300x200.jpg\" alt=\"\" width=\"300\" height=\"200\" srcset=\"http:\/\/www.collab.scrapyardchallenge.com\/wp-content\/uploads\/2011\/12\/IMG_5235-300x200.jpg 300w, http:\/\/www.collab.scrapyardchallenge.com\/wp-content\/uploads\/2011\/12\/IMG_5235-1024x682.jpg 1024w\" sizes=\"auto, (max-width: 300px) 100vw, 300px\" \/><\/a><\/p>\n<p><a href=\"..\/wp-content\/uploads\/2011\/12\/IMG_5234.jpg\"><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-medium wp-image-1154\" src=\"..\/wp-content\/uploads\/2011\/12\/IMG_5234-300x200.jpg\" alt=\"\" width=\"284\" height=\"190\" srcset=\"http:\/\/www.collab.scrapyardchallenge.com\/wp-content\/uploads\/2011\/12\/IMG_5234-300x200.jpg 300w, http:\/\/www.collab.scrapyardchallenge.com\/wp-content\/uploads\/2011\/12\/IMG_5234-1024x682.jpg 1024w\" sizes=\"auto, (max-width: 284px) 100vw, 284px\" \/><\/a><a href=\"http:\/\/www.collab.scrapyardchallenge.com\/wp-content\/uploads\/2011\/12\/IMG_5237.jpg\"><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-full wp-image-1156\" src=\"http:\/\/www.collab.scrapyardchallenge.com\/wp-content\/uploads\/2011\/12\/IMG_5237.jpg\" alt=\"\" width=\"307\" height=\"212\" \/><\/a><a href=\"http:\/\/www.collab.scrapyardchallenge.com\/wp-content\/uploads\/2011\/12\/IMG_5243.jpg\"><img decoding=\"async\" class=\"alignnone size-full wp-image-1157\" src=\"http:\/\/www.collab.scrapyardchallenge.com\/wp-content\/uploads\/2011\/12\/IMG_5243.jpg\" alt=\"\" \/><\/a><a href=\"http:\/\/www.collab.scrapyardchallenge.com\/wp-content\/uploads\/2011\/12\/test.jpg\"><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-large wp-image-1158\" src=\"http:\/\/www.collab.scrapyardchallenge.com\/wp-content\/uploads\/2011\/12\/test-1024x662.jpg\" alt=\"\" width=\"590\" height=\"381\" srcset=\"http:\/\/www.collab.scrapyardchallenge.com\/wp-content\/uploads\/2011\/12\/test-1024x662.jpg 1024w, http:\/\/www.collab.scrapyardchallenge.com\/wp-content\/uploads\/2011\/12\/test-300x194.jpg 300w\" sizes=\"auto, (max-width: 590px) 100vw, 590px\" \/><\/a><\/p>\n<p><strong>Here is the code for arduino :<\/strong><\/p>\n<p>#include &lt;Charliplexing.h&gt;<br \/>\n#include &lt;fix_fft.h&gt;<\/p>\n<p>#define AUDIOPIN 5<\/p>\n<p>int press1 = 0;<br \/>\nint val1 = 0;<\/p>\n<p>char im[128], data[128];<\/p>\n<p>char data_avgs[14];<\/p>\n<p>int i=0,val;<\/p>\n<p>void setup() {<br \/>\nLedSign::Init(); \/\/Initilizes the LoL Shield<br \/>\nSerial.begin(9600);<br \/>\n}<\/p>\n<p>void loop() {<\/p>\n<p>for (i=0; i &lt; 128; i++){<br \/>\nval = analogRead(AUDIOPIN);<br \/>\ndata[i] = val;<br \/>\nim[i] = 0;<br \/>\n};<\/p>\n<p>fix_fft(data, im, 7, 0);<\/p>\n<p>for (i=0; i&lt; 64; i++){<br \/>\ndata[i] = sqrt(data[i] * data[i] + im[i] * im[i]); \/\/ this gets the absolute value of the values in the array, so we&#8217;re only dealing with positive numbers<br \/>\n};<\/p>\n<p>\/\/ average bars together<br \/>\nfor (i=0; i&lt; 14; i++) {<br \/>\ndata_avgs[i] = data[i*4] + data[i*4 + 1] + data[i*4 + 2] + data[i*4 + 3]; \/\/ average together<br \/>\ndata_avgs[i] = map(data_avgs[i], 0, 30, 0, 9); \/\/ remap values for LoL<br \/>\n}<br \/>\n\/\/ set LoLShield<\/p>\n<p>for (int x=0; x &lt; 14; x++) {<br \/>\nfor (int y=0; y &lt; 9; y++) {<br \/>\nif (y &lt; data_avgs[13-x]) { \/\/ 13-x reverses the bars so low to high frequences are represented from left to right.<br \/>\nLedSign::Set(x,y,1); \/\/ set the LED on<br \/>\n}<br \/>\nelse {<br \/>\nLedSign::Set(x,y,0); \/\/ set the LED off<br \/>\n}<br \/>\n}<br \/>\n}<\/p>\n<p>val1=analogRead(press1);<br \/>\n\/\/Serial.println(val1);<\/p>\n<p>\/\/Serial.println(val1);<br \/>\nSerial.write(val1);<\/p>\n<p>}<\/p>\n<p><strong>Here is the code for processing :<\/strong><\/p>\n<p>\/\/&#8212;&#8212;&#8212;&#8212;&#8212;&#8212; Serial Variables &#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8211;<br \/>\n\/\/this is a library we are importing into this sketch<br \/>\nimport processing.serial.*;<br \/>\nSerial myPort;\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 \/\/ The serial port<br \/>\nint[] serialInArray = new int[1];\u00a0\u00a0\u00a0 \/\/ Where we&#8217;ll put what we receive<br \/>\nint serialCount = 0;\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 \/\/ A count of how many bytes we receive<br \/>\nboolean firstContact = false;\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 \/\/ Whether we&#8217;ve heard from the microcontroller<br \/>\nint sensor1;\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 \/\/ Our Incoming Sensor variables<br \/>\nint oldsensor1;\u00a0 \/\/Saved Sesnor vars<br \/>\n\/\/&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;-<\/p>\n<p>import ddf.minim.*;<\/p>\n<p>AudioPlayer player;<br \/>\nMinim minim;<br \/>\nTimer timer;<\/p>\n<p>int val1=0;<\/p>\n<p>boolean checkForce = true;<\/p>\n<p>void setup() {<\/p>\n<p>String portName = Serial.list()[0];<br \/>\nmyPort = new Serial(this, portName, 9600);<\/p>\n<p>size(800, 800,P2D);<br \/>\nminim = new Minim(this);<br \/>\nplayer = minim.loadFile(&#8220;tasteyou.mp3&#8221;, 2048);<\/p>\n<p>}<\/p>\n<p>void draw () {<br \/>\nbackground(0);<br \/>\nstroke(255);<\/p>\n<p>if (checkForce == true)<br \/>\nplayer.play();<br \/>\nelse<br \/>\nplayer.pause();<br \/>\n\/\/ println(checkForce);<br \/>\n}<\/p>\n<p>void serialEvent(Serial myPort) {<\/p>\n<p>val1 = myPort.read();\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 \/\/ read it and store it in val<br \/>\nif (val1 &gt; 0) checkForce = true;<br \/>\nelse checkForce = false;<\/p>\n<p>\/\/println(val1);<br \/>\n}<\/p>\n","protected":false},"excerpt":{"rendered":"<p>I was lucky enough to win a bet with a friend (something about the melting temperature of a plastic..) and got his superb grammaphone. Here&#8217;s what i wanted to do : i will place a woofer inside of the grammaphone&#8217;s horn, and connect it to an amplifier, an arduino and a computer. It will basically &hellip; <\/p>\n<p><a class=\"more-link btn\" href=\"http:\/\/www.collab.scrapyardchallenge.com\/?p=1143\">Continue reading<\/a><\/p>\n","protected":false},"author":3,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[1],"tags":[],"class_list":["post-1143","post","type-post","status-publish","format-standard","hentry","category-uncategorized","item-wrap"],"_links":{"self":[{"href":"http:\/\/www.collab.scrapyardchallenge.com\/index.php?rest_route=\/wp\/v2\/posts\/1143","targetHints":{"allow":["GET"]}}],"collection":[{"href":"http:\/\/www.collab.scrapyardchallenge.com\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"http:\/\/www.collab.scrapyardchallenge.com\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"http:\/\/www.collab.scrapyardchallenge.com\/index.php?rest_route=\/wp\/v2\/users\/3"}],"replies":[{"embeddable":true,"href":"http:\/\/www.collab.scrapyardchallenge.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=1143"}],"version-history":[{"count":5,"href":"http:\/\/www.collab.scrapyardchallenge.com\/index.php?rest_route=\/wp\/v2\/posts\/1143\/revisions"}],"predecessor-version":[{"id":1148,"href":"http:\/\/www.collab.scrapyardchallenge.com\/index.php?rest_route=\/wp\/v2\/posts\/1143\/revisions\/1148"}],"wp:attachment":[{"href":"http:\/\/www.collab.scrapyardchallenge.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=1143"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"http:\/\/www.collab.scrapyardchallenge.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=1143"},{"taxonomy":"post_tag","embeddable":true,"href":"http:\/\/www.collab.scrapyardchallenge.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=1143"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}