{"id":168,"date":"2015-10-07T02:56:05","date_gmt":"2015-10-07T02:56:05","guid":{"rendered":"http:\/\/www.aaronparsekian.com\/?p=168"},"modified":"2015-10-07T02:56:05","modified_gmt":"2015-10-07T02:56:05","slug":"assignment-4-analog-outputs-with-the-arduino","status":"publish","type":"post","link":"http:\/\/www.aaronparsekian.com\/?p=168","title":{"rendered":"Assignment #4 &#8211; Analog outputs with the arduino"},"content":{"rendered":"<p>This weeks lab covered interfacing the Arduino with servo motors and speakers. The servo lab basically involves mapping the range of an analog input (variable resistor) to the servo motors full rotation.<\/p>\n<p><a href=\"http:\/\/www.aaronparsekian.com\/wp-content\/uploads\/2015\/10\/FullSizeRender-5.jpg\"><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-medium wp-image-170\" src=\"http:\/\/www.aaronparsekian.com\/wp-content\/uploads\/2015\/10\/FullSizeRender-5-300x225.jpg\" alt=\"FullSizeRender 5\" width=\"300\" height=\"225\" srcset=\"http:\/\/www.aaronparsekian.com\/wp-content\/uploads\/2015\/10\/FullSizeRender-5-300x225.jpg 300w, http:\/\/www.aaronparsekian.com\/wp-content\/uploads\/2015\/10\/FullSizeRender-5-1024x768.jpg 1024w\" sizes=\"auto, (max-width: 300px) 100vw, 300px\" \/><\/a><\/p>\n<p>The tone lab uses the tone library in Arduino to map an analog input to a frequency range on the speaker.<\/p>\n<p><a href=\"http:\/\/www.aaronparsekian.com\/wp-content\/uploads\/2015\/10\/FullSizeRender-4.jpg\"><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-medium wp-image-169\" src=\"http:\/\/www.aaronparsekian.com\/wp-content\/uploads\/2015\/10\/FullSizeRender-4-300x225.jpg\" alt=\"FullSizeRender 4\" width=\"300\" height=\"225\" srcset=\"http:\/\/www.aaronparsekian.com\/wp-content\/uploads\/2015\/10\/FullSizeRender-4-300x225.jpg 300w, http:\/\/www.aaronparsekian.com\/wp-content\/uploads\/2015\/10\/FullSizeRender-4-1024x768.jpg 1024w\" sizes=\"auto, (max-width: 300px) 100vw, 300px\" \/><\/a><\/p>\n<p>I decided now would be a great time for me to use this nintendo DS touchscreen that I had lying around. <a href=\"https:\/\/www.sparkfun.com\/products\/retired\/8977\">Sparkfun<\/a> has some great information on how to use this screen. Basically it is two variable resistor arrays. One for X values and one for Y values.<\/p>\n<p><a href=\"http:\/\/www.aaronparsekian.com\/wp-content\/uploads\/2015\/10\/bussbarslarge.jpg\"><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-medium wp-image-171\" src=\"http:\/\/www.aaronparsekian.com\/wp-content\/uploads\/2015\/10\/bussbarslarge-300x212.jpg\" alt=\"bussbarslarge\" width=\"300\" height=\"212\" srcset=\"http:\/\/www.aaronparsekian.com\/wp-content\/uploads\/2015\/10\/bussbarslarge-300x212.jpg 300w, http:\/\/www.aaronparsekian.com\/wp-content\/uploads\/2015\/10\/bussbarslarge-1024x722.jpg 1024w, http:\/\/www.aaronparsekian.com\/wp-content\/uploads\/2015\/10\/bussbarslarge.jpg 1089w\" sizes=\"auto, (max-width: 300px) 100vw, 300px\" \/><\/a><\/p>\n<p>I found some code by John Boxall very helpful. (http:\/\/tronixstuff.com\/2010\/12\/29\/tutorial-arduino-and-the-ds-touch-screen) \u00a0He explains how to alternate pins between analogWrite\u00a0and analogRead in order to get the touch screen to work on its four connections.<\/p>\n<p>I decided to map the touch screen to four sections, similar to what we learned in ICM early on with p5.js.<\/p>\n<div class=\"oembed-gist\"><script src=\"https:\/\/gist.github.com\/aaronparsekian\/f16ea3f635a14de78267.js\"><\/script><noscript>View the code on <a href=\"https:\/\/gist.github.com\/aaronparsekian\/f16ea3f635a14de78267\">Gist<\/a>.<\/noscript><\/div>\n<p>I used these four sections to toggle between four colors. Here is the final product:<\/p>\n<p><iframe loading=\"lazy\" title=\"IMG_1003\" src=\"https:\/\/player.vimeo.com\/video\/141621708?dnt=1&amp;app_id=122963\" width=\"660\" height=\"371\" frameborder=\"0\" allow=\"autoplay; fullscreen; picture-in-picture; clipboard-write\"><\/iframe><\/p>\n<p>&nbsp;<\/p>\n","protected":false},"excerpt":{"rendered":"<p>This weeks lab covered interfacing the Arduino with servo motors and speakers. The servo lab basically involves mapping the range of an analog input (variable resistor) to the servo motors full rotation. The tone lab uses the tone library in Arduino to map an analog input to a frequency range on the speaker. I decided &hellip; <a href=\"http:\/\/www.aaronparsekian.com\/?p=168\" class=\"more-link\">Continue reading <span class=\"screen-reader-text\">Assignment #4 &#8211; Analog outputs with the arduino<\/span><\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[8,3],"tags":[],"class_list":["post-168","post","type-post","status-publish","format-standard","hentry","category-fall-2015","category-pcomp"],"_links":{"self":[{"href":"http:\/\/www.aaronparsekian.com\/index.php?rest_route=\/wp\/v2\/posts\/168","targetHints":{"allow":["GET"]}}],"collection":[{"href":"http:\/\/www.aaronparsekian.com\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"http:\/\/www.aaronparsekian.com\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"http:\/\/www.aaronparsekian.com\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"http:\/\/www.aaronparsekian.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=168"}],"version-history":[{"count":1,"href":"http:\/\/www.aaronparsekian.com\/index.php?rest_route=\/wp\/v2\/posts\/168\/revisions"}],"predecessor-version":[{"id":172,"href":"http:\/\/www.aaronparsekian.com\/index.php?rest_route=\/wp\/v2\/posts\/168\/revisions\/172"}],"wp:attachment":[{"href":"http:\/\/www.aaronparsekian.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=168"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"http:\/\/www.aaronparsekian.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=168"},{"taxonomy":"post_tag","embeddable":true,"href":"http:\/\/www.aaronparsekian.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=168"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}