{"id":71,"date":"2014-09-16T18:21:00","date_gmt":"2014-09-16T18:21:00","guid":{"rendered":"http:\/\/itp.fromjia.com\/?p=71"},"modified":"2014-09-27T02:06:37","modified_gmt":"2014-09-27T02:06:37","slug":"lab-2-inputoutput","status":"publish","type":"post","link":"http:\/\/itp.fromjia.com\/?p=71","title":{"rendered":"Lab 2: Input\/output"},"content":{"rendered":"<p>For my second lab assignment, I connected a <a href=\"https:\/\/itp.nyu.edu\/physcomp\/labs\/labs-arduino-digital-and-analog\/digital-input-and-output-with-an-arduino\/\"><em>digital input and output<\/em><\/a> circuit and an <a href=\"https:\/\/itp.nyu.edu\/physcomp\/labs\/labs-arduino-digital-and-analog\/analog-in-with-an-arduino\/\"><em>analog input<\/em><\/a> circuit. (images below) The difference between a digital input and an analog input is that digital input can only sense two states (that&#8217;s why it&#8217;s also called binary input), on and off, and analog input can read a variable voltage. The range of an analog input is usually between 0 and the maximum voltage that the micro-controller can take. But the range can change depending on the physical context. In these instances, I should use the real range rather than the maximum range of the analog sensor.<\/p>\n<p>There are various differences in working with digital input versus analog input. For one, an analog input requires an <em>analog-to-digital converter (ADC)<\/em> to read the voltage change and convert it into digital form, because the micro-controller can only read two input values, 0V and 5V. The ADC is built in the Arduino. With a digital input there is not need to convert the voltage.<\/p>\n<p>Secondly, an analog input is less stable than a digital input. To smooth out the dips and spikes that goes into the circuit when inputing with an analog sensor, I need to decouple the input with a <em>decoupling capacitor.\u00a0<\/em>(Capacitors are used to smooth out signals, by storing energy when the current is passing through and releasing it later.) Also, I should introduce a small delay after reading each sensor, to give the micro-controller time to stabilize before reading the next sensor.<\/p>\n<p>Digital output is pretty straightforward \u2013 it turns something, such as a LED, on or off.<\/p>\n<p><b>Issues:\u00a0<\/b><\/p>\n<ul>\n<li><del>I had some issues with digital I\/O when I tried to make my own switch with metal sheets. The LEDs lit and responded to the switch, but didn&#8217;t follow the correct order of the program, i.e. yellow off, red on when switch is off and the reverse then the switch is on.<\/del><\/li>\n<\/ul>\n<p><strong>Questions:<\/strong><\/p>\n<ul>\n<li><del>I&#8217;m still not sure how to find the real range of an analog sensor in\u00a0practice.<\/del><\/li>\n<li><del>I had encountered debouncing in another class when we used the Flora. What&#8217;s the difference between decoupling and debouncing?<\/del><\/li>\n<li><del>How do you know which size of decoupling capacitor to use in an analog input circuit?<\/del><\/li>\n<\/ul>\n<p><b>Other:<\/b><\/p>\n<ul>\n<li><del>I\u00a0briefly looked at the serial monitor for input data, but I still don&#8217;t totally understand how it works. I&#8217;ll look more into that.<\/del><\/li>\n<\/ul>\n<div id=\"attachment_80\" style=\"width: 740px\" class=\"wp-caption alignnone\"><a href=\"http:\/\/itp.fromjia.com\/wp-content\/uploads\/2014\/09\/Screen-Shot-2014-09-16-at-1.24.34-PM.png\"><img loading=\"lazy\" decoding=\"async\" aria-describedby=\"caption-attachment-80\" class=\"size-large wp-image-80\" src=\"http:\/\/itp.fromjia.com\/wp-content\/uploads\/2014\/09\/Screen-Shot-2014-09-16-at-1.24.34-PM-1024x488.png\" alt=\"Digital I\/O\" width=\"730\" height=\"347\" srcset=\"http:\/\/itp.fromjia.com\/wp-content\/uploads\/2014\/09\/Screen-Shot-2014-09-16-at-1.24.34-PM-1024x488.png 1024w, http:\/\/itp.fromjia.com\/wp-content\/uploads\/2014\/09\/Screen-Shot-2014-09-16-at-1.24.34-PM-300x143.png 300w, http:\/\/itp.fromjia.com\/wp-content\/uploads\/2014\/09\/Screen-Shot-2014-09-16-at-1.24.34-PM-1200x572.png 1200w, http:\/\/itp.fromjia.com\/wp-content\/uploads\/2014\/09\/Screen-Shot-2014-09-16-at-1.24.34-PM.png 1362w\" sizes=\"auto, (max-width: 730px) 100vw, 730px\" \/><\/a><p id=\"caption-attachment-80\" class=\"wp-caption-text\">Digital I\/O<\/p><\/div>\n<div id=\"attachment_73\" style=\"width: 410px\" class=\"wp-caption alignnone\"><a href=\"http:\/\/itp.fromjia.com\/wp-content\/uploads\/2014\/09\/button.gif\"><img loading=\"lazy\" decoding=\"async\" aria-describedby=\"caption-attachment-73\" class=\"size-full wp-image-73\" src=\"http:\/\/itp.fromjia.com\/wp-content\/uploads\/2014\/09\/button.gif\" alt=\"Digital I\/O with one button. \" width=\"400\" height=\"225\" \/><\/a><p id=\"caption-attachment-73\" class=\"wp-caption-text\">Digital I\/O with one button.<\/p><\/div>\n<div id=\"attachment_75\" style=\"width: 410px\" class=\"wp-caption alignnone\"><a href=\"http:\/\/itp.fromjia.com\/wp-content\/uploads\/2014\/09\/DIYbutton.gif\"><img loading=\"lazy\" decoding=\"async\" aria-describedby=\"caption-attachment-75\" class=\"size-full wp-image-75\" src=\"http:\/\/itp.fromjia.com\/wp-content\/uploads\/2014\/09\/DIYbutton.gif\" alt=\"Digital I\/O with DIY button. **Issue: both LEDs are lit when the switch is off, when the yellow LED should be off. \" width=\"400\" height=\"225\" \/><\/a><p id=\"caption-attachment-75\" class=\"wp-caption-text\">Digital I\/O with DIY button. **Issue: both LEDs are lit when the switch is off, when the yellow LED should be off.<\/p><\/div>\n<div id=\"attachment_84\" style=\"width: 410px\" class=\"wp-caption alignnone\"><a href=\"http:\/\/itp.fromjia.com\/wp-content\/uploads\/2014\/09\/DIYbutton2.gif\"><img loading=\"lazy\" decoding=\"async\" aria-describedby=\"caption-attachment-84\" class=\"size-full wp-image-84\" src=\"http:\/\/itp.fromjia.com\/wp-content\/uploads\/2014\/09\/DIYbutton2.gif\" alt=\"Digital I\/O with DIY switch2. **Issue: again, both LEDs are lit when the switch is off. \" width=\"400\" height=\"225\" \/><\/a><p id=\"caption-attachment-84\" class=\"wp-caption-text\">Digital I\/O with DIY switch2. **Issue: again, both LEDs are lit when the switch is off.<\/p><\/div>\n<div id=\"attachment_81\" style=\"width: 740px\" class=\"wp-caption alignnone\"><a href=\"http:\/\/itp.fromjia.com\/wp-content\/uploads\/2014\/09\/Screen-Shot-2014-09-16-at-2.18.23-PM.png\"><img loading=\"lazy\" decoding=\"async\" aria-describedby=\"caption-attachment-81\" class=\"size-large wp-image-81\" src=\"http:\/\/itp.fromjia.com\/wp-content\/uploads\/2014\/09\/Screen-Shot-2014-09-16-at-2.18.23-PM-1024x475.png\" alt=\"Analog input.\" width=\"730\" height=\"338\" srcset=\"http:\/\/itp.fromjia.com\/wp-content\/uploads\/2014\/09\/Screen-Shot-2014-09-16-at-2.18.23-PM-1024x475.png 1024w, http:\/\/itp.fromjia.com\/wp-content\/uploads\/2014\/09\/Screen-Shot-2014-09-16-at-2.18.23-PM-300x139.png 300w, http:\/\/itp.fromjia.com\/wp-content\/uploads\/2014\/09\/Screen-Shot-2014-09-16-at-2.18.23-PM-1200x556.png 1200w, http:\/\/itp.fromjia.com\/wp-content\/uploads\/2014\/09\/Screen-Shot-2014-09-16-at-2.18.23-PM.png 1362w\" sizes=\"auto, (max-width: 730px) 100vw, 730px\" \/><\/a><p id=\"caption-attachment-81\" class=\"wp-caption-text\">Analog input.<\/p><\/div>\n<div id=\"attachment_79\" style=\"width: 410px\" class=\"wp-caption alignnone\"><a href=\"http:\/\/itp.fromjia.com\/wp-content\/uploads\/2014\/09\/potentiameter1.gif\"><img loading=\"lazy\" decoding=\"async\" aria-describedby=\"caption-attachment-79\" class=\"size-full wp-image-79\" src=\"http:\/\/itp.fromjia.com\/wp-content\/uploads\/2014\/09\/potentiameter1.gif\" alt=\"Analog input with a potentiometer. \" width=\"400\" height=\"225\" \/><\/a><p id=\"caption-attachment-79\" class=\"wp-caption-text\">Analog input with a potentiometer.<\/p><\/div>\n<div id=\"attachment_82\" style=\"width: 410px\" class=\"wp-caption alignnone\"><a href=\"http:\/\/itp.fromjia.com\/wp-content\/uploads\/2014\/09\/forcesensor.gif\"><img loading=\"lazy\" decoding=\"async\" aria-describedby=\"caption-attachment-82\" class=\"size-full wp-image-82\" src=\"http:\/\/itp.fromjia.com\/wp-content\/uploads\/2014\/09\/forcesensor.gif\" alt=\"Analog input with a force sensing resistor. \" width=\"400\" height=\"225\" \/><\/a><p id=\"caption-attachment-82\" class=\"wp-caption-text\">Analog input with a force sensing resistor.<\/p><\/div>\n<p>&nbsp;<\/p>\n<p>&nbsp;<\/p>\n","protected":false},"excerpt":{"rendered":"<p>For my second lab assignment, I connected a digital input and output circuit and an analog input circuit. (images below) The difference between a digital input and an analog input is that digital input can only sense two states (that&#8217;s why it&#8217;s also called binary input), on and off, and analog input can read a [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[3],"tags":[],"class_list":["post-71","post","type-post","status-publish","format-standard","hentry","category-physical-computing"],"_links":{"self":[{"href":"http:\/\/itp.fromjia.com\/index.php?rest_route=\/wp\/v2\/posts\/71","targetHints":{"allow":["GET"]}}],"collection":[{"href":"http:\/\/itp.fromjia.com\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"http:\/\/itp.fromjia.com\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"http:\/\/itp.fromjia.com\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"http:\/\/itp.fromjia.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=71"}],"version-history":[{"count":8,"href":"http:\/\/itp.fromjia.com\/index.php?rest_route=\/wp\/v2\/posts\/71\/revisions"}],"predecessor-version":[{"id":174,"href":"http:\/\/itp.fromjia.com\/index.php?rest_route=\/wp\/v2\/posts\/71\/revisions\/174"}],"wp:attachment":[{"href":"http:\/\/itp.fromjia.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=71"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"http:\/\/itp.fromjia.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=71"},{"taxonomy":"post_tag","embeddable":true,"href":"http:\/\/itp.fromjia.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=71"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}