<div class="post_tit_area" style="position: relative; margin: 0px auto; padding: 36px 0px 30px; border-bottom: 1px solid rgb(230, 230, 230); width: 640px; font-family: -apple-system, BlinkMacSystemFont, Roboto, sans-serif; font-size: 14px; background-color: #ffffff;">
   <div class="tit_area ">
      <h3 class="tit_h3" style="margin: 0px; padding: 0px; font-size: 2.143em; line-height: 1.3em; font-family: AppleSDGothicNeo-Bold; color: #161616; word-break: break-word;">ReadAnalogVoltage에서의 전압 오차의 보정</h3>
      </div>
   <div class="author_area" style="overflow: hidden; padding: 24px 100px 0px 0px; -webkit-font-smoothing: antialiased;"><a href="https://m.blog.naver.com/PostList.nhn?blogId=mkhee77" class="se_thumbnail" style="color: #000000; text-decoration-line: none; cursor: pointer; -webkit-tap-highlight-color: rgba(0, 0, 0, 0.1); float: left; position: relative; padding-right: 10px;" target="_blank"><span class="img" style="display: block; overflow: hidden; position: relative; width: 36px; height: 36px; border-radius: 36px;"><img src="https://blogpfthumb-phinf.pstatic.net/MjAxOTAyMDlfMTU3/MDAxNTQ5NjYxNjAyMTY1.c6vOJvibJS41cmCS9ir8muXhG60EecfcJps9SBX-xvwg.iiWvbLY-w5GbsvLIWSjsQ_p7jhDs72-lAbCIuUfG3ikg.PNG.mkhee77/%25C4%25B8%25C3%25B3.PNG?type=s1" width="35" height="35" alt="프로필" data-top="178" style="border: 0px; vertical-align: middle; border-radius: 36px;" /></span></a>
      <div class="se_author" style="display: table-row; overflow: hidden; vertical-align: top; line-height: 20px;"><a href="https://m.blog.naver.com/PostList.nhn?blogId=mkhee77" style="color: #555555; text-decoration-line: none; cursor: pointer; -webkit-tap-highlight-color: rgba(0, 0, 0, 0.1); display: table-cell;" target="_blank"><span class="ell" style="display: -webkit-box; overflow: hidden; text-overflow: ellipsis; -webkit-line-clamp: 1; -webkit-box-orient: vertical; word-break: break-all; overflow-wrap: break-word;">아두이노로 놀기</span></a></div>
      <p class="se_date" style="padding: 3px 0px 0px; font-size: 0.857em; color: #8c8c8c; font-family: Helvetica-Light; line-height: 0.857em; letter-spacing: -0.5px;">2017. 3. 26. 15:26<span class="txt" style="font-size: 11px; white-space: nowrap;"></span></p>
      </div>
   <div class="btn_area" style="position: absolute; right: 0px; bottom: 33px; text-align: right; white-space: nowrap; font-family: &quot;Helvetica Neue&quot;, helvetica, AppleSDGothicNeo, sans-serif; -webkit-font-smoothing: antialiased;"><a href="https://m.blog.naver.com/PostView.nhn?blogId=mkhee77&amp;logNo=220967454846&amp;proxyReferer=https:%2F%2Fwww.google.com%2F#" class="btn_buddyadd _add_buddy _param(mkhee77|true||/BuddyAddForm.nhn) _returnFalse" isblackuser="" style="color: #03c75a; text-decoration-line: none; cursor: pointer; -webkit-tap-highlight-color: rgba(0, 0, 0, 0.1); display: inline-block; position: absolute; bottom: 0px; right: 21px; height: 28px; padding: 0px 13px; border: 1px solid rgb(3, 199, 90); font-size: 12px; line-height: 28px; text-align: center;" target="_blank"><span class="sp" style="display: inline-block; overflow: hidden; background-image: url(&quot;https://ssl.pstatic.net/static/blog/sp_blog87.png&quot;); background-size: 339px 320px; color: transparent; margin: 10px 0px 0px; vertical-align: top; background-position: -329px -174px; width: 7px; height: 7px;"></span>&nbsp;이웃추가</a>
      <div class="post_function_t1" style="position: absolute; bottom: 0px; right: -11px;"><button type="button" class="btn_function _btn_tools" style="margin: 0px; padding: 0px; font-size: 14px; line-height: 20px; font-family: Helvetica-Light, HelveticaNeue-Light, &quot;Helvetica Neue Light&quot;, 나눔고딕, nanumgothic, AppleSDGothicNeo, &quot;malgun gothic&quot;, &quot;맑은 고딕&quot;, sans-serif; border-width: initial; border-style: none; border-color: initial; background-image: initial; background-position: 0px 0px; background-size: initial; background-repeat: initial; background-attachment: initial; background-origin: initial; background-clip: initial; cursor: pointer; border-radius: 0px; width: 26px; height: 30px;"><span class="sp" style="position: relative; display: inline-block; overflow: hidden; background-image: url(&quot;https://ssl.pstatic.net/static/blog/sp_blog87.png&quot;); background-size: 339px 320px; color: transparent; margin: 7px 0px; vertical-align: top; background-position: -329px -145px; width: 3px; height: 16px;">본문 기타 기능</span></button></div>
      </div>
   </div>
<div class="post_ct  " id="viewTypeSelector" style="padding: 36px 20px 10px; font-size: 1.143em; line-height: 1.45em; word-break: break-all; overflow-wrap: break-word; min-height: 87px; width: 640px; margin-left: auto; margin-right: auto; background-color: #ffffff; font-family: sans-serif !important;">
   <p style="padding: 0px;">ReadAnalogVoltage 예제는 입력된 아닐로그 입력 AD값(0~1023)을 통하여 실제 입력핀의 전압을 계산하는 예제이다.</p>
   <p style="padding: 0px;">예제를 실행하여 얻은 전압값과 실제 멀티테스터를 이용하여 단자를 측정했을때의 전압값이 실제는 다르게 나온다.</p>
   <p style="padding: 0px;">이는 아날로그 ADC의 기준전압(Reference Voltage)의 오차로 볼 수 있는데, ReadAnalogVoltage 예제의 경우 기준전압을</p>
   <p style="padding: 0px;">5.0V로 하여 계산하지만, 실제 아두이노 보드에서 ADC입력의 기준이 되는 전압값은 정확히 5V가 되지 않는다.</p>
   <p style="padding: 0px;"><strike>아두이노에 입력되는 VCC전압이 정확히 5V가 아니기 때문이다.</strike></p>
   <p style="padding: 0px;">MCU인 Atmega328P에 입력되는 VCC 전압이 기준전압으로 사용되는데, 정확히 5V가 입력되지 않기 때문에 오차가 발생하게 된다.&nbsp;</p>
   <p style="padding: 0px;"><br /></p>
   <p style="padding: 0px;">예제에서 정확한 전압값을 얻기 위해서는 기준전압(Reference Voltage)을 실제전압에 맞게 보정해줄 필요가 있다.</p>
   <p style="padding: 0px;">우선 예제 소스코드를 본다.</p>
   <p style="padding: 0px;"><br /></p>
   <p style="padding: 0px;"><span style="font-weight: 600; font-family: AppleSDGothicNeo-Bold;">/*</span></p>
   <p style="padding: 0px;"><span style="font-weight: 600; font-family: AppleSDGothicNeo-Bold;">&nbsp; ReadAnalogVoltage</span></p>
   <p style="padding: 0px;"><span style="font-weight: 600; font-family: AppleSDGothicNeo-Bold;">&nbsp; Reads an analog input on pin 0, converts it to voltage, and prints the result to the serial monitor.</span></p>
   <p style="padding: 0px;"><span style="font-weight: 600; font-family: AppleSDGothicNeo-Bold;">&nbsp; Graphical representation is available using serial plotter (Tools &gt; Serial Plotter menu)</span></p>
   <p style="padding: 0px;"><span style="font-weight: 600; font-family: AppleSDGothicNeo-Bold;">&nbsp; Attach the center pin of a potentiometer to pin A0, and the outside pins to +5V and ground.</span></p>
   <p style="padding: 0px;"><span style="font-weight: 600; font-family: AppleSDGothicNeo-Bold;"><br /></span></p>
   <p style="padding: 0px;"><span style="font-weight: 600; font-family: AppleSDGothicNeo-Bold;">&nbsp; This example code is in the public domain.</span></p>
   <p style="padding: 0px;"><span style="font-weight: 600; font-family: AppleSDGothicNeo-Bold;">*/</span></p>
   <p style="padding: 0px;"><span style="font-weight: 600; font-family: AppleSDGothicNeo-Bold;"><br /></span></p>
   <p style="padding: 0px;"><span style="font-weight: 600; font-family: AppleSDGothicNeo-Bold;">// the setup routine runs once when you press reset:</span></p>
   <p style="padding: 0px;"><span style="font-weight: 600; font-family: AppleSDGothicNeo-Bold;">void setup() {</span></p>
   <p style="padding: 0px;"><span style="font-weight: 600; font-family: AppleSDGothicNeo-Bold;">&nbsp; // initialize serial communication at 9600 bits per second:</span></p>
   <p style="padding: 0px;"><span style="font-weight: 600; font-family: AppleSDGothicNeo-Bold;">&nbsp; Serial.begin(9600);</span></p>
   <p style="padding: 0px;"><span style="font-weight: 600; font-family: AppleSDGothicNeo-Bold;">}</span></p>
   <p style="padding: 0px;"><span style="font-weight: 600; font-family: AppleSDGothicNeo-Bold;"><br /></span></p>
   <p style="padding: 0px;"><span style="font-weight: 600; font-family: AppleSDGothicNeo-Bold;">// the loop routine runs over and over again forever:</span></p>
   <p style="padding: 0px;"><span style="font-weight: 600; font-family: AppleSDGothicNeo-Bold;">void loop() {</span></p>
   <p style="padding: 0px;"><span style="font-weight: 600; font-family: AppleSDGothicNeo-Bold;">&nbsp; // read the input on analog pin 0:</span></p>
   <p style="padding: 0px;"><span style="font-weight: 600; font-family: AppleSDGothicNeo-Bold;">&nbsp; int sensorValue = analogRead(A0);</span></p>
   <p style="padding: 0px;"><span style="font-weight: 600; font-family: AppleSDGothicNeo-Bold;">&nbsp; // Convert the analog reading (which goes from 0 - 1023) to a voltage (0 - 5V):</span></p>
   <p style="padding: 0px;"><span style="font-weight: 600; font-family: AppleSDGothicNeo-Bold;">&nbsp; float voltage = sensorValue * (5.0 / 1023.0);</span></p>
   <p style="padding: 0px;"><span style="font-weight: 600; font-family: AppleSDGothicNeo-Bold;">&nbsp; // print out the value you read:</span></p>
   <p style="padding: 0px;"><span style="font-weight: 600; font-family: AppleSDGothicNeo-Bold;">&nbsp; Serial.println(voltage);</span></p>
   <p style="padding: 0px;"><span style="font-weight: 600; font-family: AppleSDGothicNeo-Bold;">}</span></p>
   <p style="padding: 0px;"><span style="font-weight: 600; font-family: AppleSDGothicNeo-Bold;"><br /></span></p>
   <p style="padding: 0px;">sensorValue는 아날로그 입력단자를 통하여 아두이노가 읽는 값(0~1023)으로&nbsp;시리얼모니터를 통해 출력할 수 있는 값이고,</p>
   <p style="padding: 0px;">voltage는 아두이노가 기준전압 5.0V 기준으로 계산한 전압값이다.</p>
   <p style="padding: 0px;"><br /></p>
   <p style="padding: 0px;">위의 식 float voltage = sensorValue * (5.0 / 1023.0)에서 voltage값은 A0단자의 전압값을 측정하고, 기준전압 5.0을 Vref라는 변수로 바꾸어</p>
   <p style="padding: 0px;">Vref를 계산하여 구한다.</p>
   <p style="padding: 0px;"><br /></p>
   <p style="padding: 0px;">voltage = sensorValue * (Vref / 1023.0)</p>
   <p style="padding: 0px;">Vref = (voltage * 1023.0) / sensorValue</p>
   <p style="padding: 0px;"><br /></p>
   <p style="padding: 0px;">를 통하여 Vref를 구한 후 소스코드에 적용하면 된다.</p>
   <p style="padding: 0px;"><span style="font-weight: 600; font-family: AppleSDGothicNeo-Bold;"><br /></span></p>
   <p style="padding: 0px;">편의를 위해 시리얼모니터에 sensorValue를 같이 출력하고 2초에 한번씩 출력하도록 소스코드를 수정하였다.</p>
   <p style="padding: 0px;"><br /></p>
   <p style="padding: 0px;"><span style="font-weight: 600; font-family: AppleSDGothicNeo-Bold;">&lt;1차 수정한 소스코드&gt;</span></p>
   <p style="padding: 0px;"><span style="font-weight: 600; font-family: AppleSDGothicNeo-Bold;">/*</span></p>
   <p style="padding: 0px;"><span style="font-weight: 600; font-family: AppleSDGothicNeo-Bold;">&nbsp; ReadAnalogVoltage</span></p>
   <p style="padding: 0px;"><span style="font-weight: 600; font-family: AppleSDGothicNeo-Bold;">&nbsp; Reads an analog input on pin 0, converts it to voltage, and prints the result to the serial monitor.</span></p>
   <p style="padding: 0px;"><span style="font-weight: 600; font-family: AppleSDGothicNeo-Bold;">&nbsp; Graphical representation is available using serial plotter (Tools &gt; Serial Plotter menu)</span></p>
   <p style="padding: 0px;"><span style="font-weight: 600; font-family: AppleSDGothicNeo-Bold;">&nbsp; Attach the center pin of a potentiometer to pin A0, and the outside pins to +5V and ground.</span></p>
   <p style="padding: 0px;"><span style="font-weight: 600; font-family: AppleSDGothicNeo-Bold;"><br /></span></p>
   <p style="padding: 0px;"><span style="font-weight: 600; font-family: AppleSDGothicNeo-Bold;">&nbsp; This example code is in the public domain.</span></p>
   <p style="padding: 0px;"><span style="font-weight: 600; font-family: AppleSDGothicNeo-Bold;">*/</span></p>
   <p style="padding: 0px;"><span style="font-weight: 600; font-family: AppleSDGothicNeo-Bold;"><br /></span></p>
   <p style="padding: 0px;"><span style="font-weight: 600; font-family: AppleSDGothicNeo-Bold;">// the setup routine runs once when you press reset:</span></p>
   <p style="padding: 0px;"><span style="font-weight: 600; font-family: AppleSDGothicNeo-Bold;">void setup() {</span></p>
   <p style="padding: 0px;"><span style="font-weight: 600; font-family: AppleSDGothicNeo-Bold;">&nbsp; // initialize serial communication at 9600 bits per second:</span></p>
   <p style="padding: 0px;"><span style="font-weight: 600; font-family: AppleSDGothicNeo-Bold;">&nbsp; Serial.begin(9600);</span></p>
   <p style="padding: 0px;"><span style="font-weight: 600; font-family: AppleSDGothicNeo-Bold;">}</span></p>
   <p style="padding: 0px;"><span style="font-weight: 600; font-family: AppleSDGothicNeo-Bold;"><br /></span></p>
   <p style="padding: 0px;"><span style="font-weight: 600; font-family: AppleSDGothicNeo-Bold;">// the loop routine runs over and over again forever:</span></p>
   <p style="padding: 0px;"><span style="font-weight: 600; font-family: AppleSDGothicNeo-Bold;">void loop() {</span></p>
   <p style="padding: 0px;"><span style="font-weight: 600; font-family: AppleSDGothicNeo-Bold;">&nbsp; // read the input on analog pin 0:</span></p>
   <p style="padding: 0px;"><span style="font-weight: 600; font-family: AppleSDGothicNeo-Bold;">&nbsp; int sensorValue = analogRead(A0);</span></p>
   <p style="padding: 0px;"><span style="font-weight: 600; font-family: AppleSDGothicNeo-Bold;">&nbsp; // Convert the analog reading (which goes from 0 - 1023) to a voltage (0 - 5V):</span></p>
   <p style="padding: 0px;"><span style="font-weight: 600; font-family: AppleSDGothicNeo-Bold;">&nbsp; float voltage = sensorValue * (5.0 / 1023.0);</span></p>
   <p style="padding: 0px;"><span style="font-weight: 600; font-family: AppleSDGothicNeo-Bold;">&nbsp; // print out the value you read:</span></p>
   <p style="padding: 0px;"><span style="font-weight: 600; font-family: AppleSDGothicNeo-Bold;">&nbsp; Serial.println(sensorValue);</span></p>
   <p style="padding: 0px;"><span style="font-weight: 600; font-family: AppleSDGothicNeo-Bold;">&nbsp; Serial.println(voltage);</span></p>
   <p style="padding: 0px;"><span style="font-weight: 600; font-family: AppleSDGothicNeo-Bold;">&nbsp; delay(2000);</span></p>
   <p style="padding: 0px;"><span style="font-weight: 600; font-family: AppleSDGothicNeo-Bold;">}</span></p>
   <p style="padding: 0px;"><span style="font-weight: 600; font-family: AppleSDGothicNeo-Bold;"><br /></span></p>
   <p style="padding: 0px;"><span class="_img  fx" thumburl="https://mblogthumb-phinf.pstatic.net/MjAxNzAzMjZfMjgg/MDAxNDkwNTA3MjE0NjM5.GZDqB3Y8Yd0Mk5Gnr2X1mS-MihGBr5f4cbDhkPs5Zj4g.cLe64WDbPaCXJmMTYmwicM1salUnShizK0yN_SLOzjgg.JPEG.mkhee77/%EC%BA%A1%EC%B2%98vo.JPG?type=" style="max-width: 100%;"><img src="https://mblogthumb-phinf.pstatic.net/MjAxNzAzMjZfMjgg/MDAxNDkwNTA3MjE0NjM5.GZDqB3Y8Yd0Mk5Gnr2X1mS-MihGBr5f4cbDhkPs5Zj4g.cLe64WDbPaCXJmMTYmwicM1salUnShizK0yN_SLOzjgg.JPEG.mkhee77/%EC%BA%A1%EC%B2%98vo.JPG?type=w2" largesrc="javascript:location.href='https://mblogthumb-phinf.pstatic.net/MjAxNzAzMjZfMjgg/MDAxNDkwNTA3MjE0NjM5.GZDqB3Y8Yd0Mk5Gnr2X1mS-MihGBr5f4cbDhkPs5Zj4g.cLe64WDbPaCXJmMTYmwicM1salUnShizK0yN_SLOzjgg.JPEG.mkhee77/%EC%BA%A1%EC%B2%98vo.JPG?type=w2'" id="img_1" data-top="2374" style="border: 0px; vertical-align: top; max-width: 100%;" /></span></p>
   <p style="padding: 0px;">&nbsp;--&gt; sensorValue = 866, voltage = 4.23V 이다.</p>
   <p style="padding: 0px;"><br /></p>
   <p style="padding: 0px;">다음은 A0 단자의 실제 전압 측정값이다.</p>
   <p style="padding: 0px;"><br /></p>
   <p style="padding: 0px;"><span class="_img  fx" thumburl="https://mblogthumb-phinf.pstatic.net/MjAxNzAzMjZfMzMg/MDAxNDkwNTA3NDYzNTIy.8Q7W_iKuO9ACU7-NYwJCt_BVPwUU1w4oA_2W9_nAiwIg.9vm2hMsSJlVWh4a-qwBIm6eD0Sl6tqihvY7d8AMDYgog.JPEG.mkhee77/20170326_144643.jpg?type=" style="max-width: 100%;"><img src="https://mblogthumb-phinf.pstatic.net/MjAxNzAzMjZfMzMg/MDAxNDkwNTA3NDYzNTIy.8Q7W_iKuO9ACU7-NYwJCt_BVPwUU1w4oA_2W9_nAiwIg.9vm2hMsSJlVWh4a-qwBIm6eD0Sl6tqihvY7d8AMDYgog.JPEG.mkhee77/20170326_144643.jpg?type=w2" largesrc="javascript:location.href='https://mblogthumb-phinf.pstatic.net/MjAxNzAzMjZfMzMg/MDAxNDkwNTA3NDYzNTIy.8Q7W_iKuO9ACU7-NYwJCt_BVPwUU1w4oA_2W9_nAiwIg.9vm2hMsSJlVWh4a-qwBIm6eD0Sl6tqihvY7d8AMDYgog.JPEG.mkhee77/20170326_144643.jpg?type=w2'" id="img_2" data-top="2973" style="border: 0px; vertical-align: top; max-width: 100%;" /></span>&nbsp;</p>
   <p style="padding: 0px;">--&gt; 3.955V 이다.</p>
   <p style="padding: 0px;">계산기로 뚜드려 할 수도 있지만, 아두이노를 활용하여 해야겠다.</p>
   <p style="padding: 0px;"><br /></p>
   <p style="padding: 0px;"><br /></p>
   <p style="padding: 0px;"><span style="font-weight: 600; font-family: AppleSDGothicNeo-Bold;">&lt;최종 수정한 소스코드&gt;</span></p>
   <p style="padding: 0px;"><span style="font-weight: 600; font-family: AppleSDGothicNeo-Bold;"><br /></span></p>
   <p style="padding: 0px;"><span style="font-weight: 600; font-family: AppleSDGothicNeo-Bold;">/*</span></p>
   <p style="padding: 0px;"><span style="font-weight: 600; font-family: AppleSDGothicNeo-Bold;">&nbsp; ReadAnalogVoltage</span></p>
   <p style="padding: 0px;"><span style="font-weight: 600; font-family: AppleSDGothicNeo-Bold;">&nbsp; Reads an analog input on pin 0, converts it to voltage, and prints the result to the serial monitor.</span></p>
   <p style="padding: 0px;"><span style="font-weight: 600; font-family: AppleSDGothicNeo-Bold;">&nbsp; Graphical representation is available using serial plotter (Tools &gt; Serial Plotter menu)</span></p>
   <p style="padding: 0px;"><span style="font-weight: 600; font-family: AppleSDGothicNeo-Bold;">&nbsp; Attach the center pin of a potentiometer to pin A0, and the outside pins to +5V and ground.</span></p>
   <p style="padding: 0px;"><span style="font-weight: 600; font-family: AppleSDGothicNeo-Bold;"><br /></span></p>
   <p style="padding: 0px;"><span style="font-weight: 600; font-family: AppleSDGothicNeo-Bold;">&nbsp; This example code is in the public domain.</span></p>
   <p style="padding: 0px;"><span style="font-weight: 600; font-family: AppleSDGothicNeo-Bold;">*/</span></p>
   <p style="padding: 0px;"><span style="font-weight: 600; font-family: AppleSDGothicNeo-Bold;">float Vin = 3.955, voltage, Vref;</span></p>
   <p style="padding: 0px;"><span style="font-weight: 600; font-family: AppleSDGothicNeo-Bold;">int sensorValue;</span></p>
   <p style="padding: 0px;"><span style="font-weight: 600; font-family: AppleSDGothicNeo-Bold;"><br /></span></p>
   <p style="padding: 0px;"><span style="font-weight: 600; font-family: AppleSDGothicNeo-Bold;">// the setup routine runs once when you press reset:</span></p>
   <p style="padding: 0px;"><span style="font-weight: 600; font-family: AppleSDGothicNeo-Bold;">void setup() {</span></p>
   <p style="padding: 0px;"><span style="font-weight: 600; font-family: AppleSDGothicNeo-Bold;">&nbsp; // initialize serial communication at 9600 bits per second:</span></p>
   <p style="padding: 0px;"><span style="font-weight: 600; font-family: AppleSDGothicNeo-Bold;">&nbsp; Serial.begin(9600);</span></p>
   <p style="padding: 0px;"><span style="font-weight: 600; font-family: AppleSDGothicNeo-Bold;">&nbsp; // read the input on analog pin 0:</span></p>
   <p style="padding: 0px;"><span style="font-weight: 600; font-family: AppleSDGothicNeo-Bold;">&nbsp; sensorValue = analogRead(A0);</span></p>
   <p style="padding: 0px;"><span style="font-weight: 600; font-family: AppleSDGothicNeo-Bold;">&nbsp; // Convert the analog reading (which goes from 0 - 1023) to a voltage (0 - 5V):</span></p>
   <p style="padding: 0px;"><span style="font-weight: 600; font-family: AppleSDGothicNeo-Bold;">&nbsp; voltage = sensorValue * (5.0 / 1023.0);</span></p>
   <p style="padding: 0px;"><span style="font-weight: 600; font-family: AppleSDGothicNeo-Bold;">&nbsp; // print out the value you read:</span></p>
   <p style="padding: 0px;"><span style="font-weight: 600; font-family: AppleSDGothicNeo-Bold;">&nbsp; Serial.println(sensorValue);</span></p>
   <p style="padding: 0px;"><span style="font-weight: 600; font-family: AppleSDGothicNeo-Bold;">&nbsp; Serial.println(voltage);</span></p>
   <p style="padding: 0px;"><span style="font-weight: 600; font-family: AppleSDGothicNeo-Bold;">&nbsp; delay(2000);</span></p>
   <p style="padding: 0px;"><span style="font-weight: 600; font-family: AppleSDGothicNeo-Bold;">}</span></p>
   <p style="padding: 0px;"><span style="font-weight: 600; font-family: AppleSDGothicNeo-Bold;"><br /></span></p>
   <p style="padding: 0px;"><span style="font-weight: 600; font-family: AppleSDGothicNeo-Bold;">// the loop routine runs over and over again forever:</span></p>
   <p style="padding: 0px;"><span style="font-weight: 600; font-family: AppleSDGothicNeo-Bold;">void loop() {</span></p>
   <p style="padding: 0px;"><span style="font-weight: 600; font-family: AppleSDGothicNeo-Bold;">&nbsp; // read the input on analog pin 0:</span></p>
   <p style="padding: 0px;"><span style="font-weight: 600; font-family: AppleSDGothicNeo-Bold;">&nbsp; sensorValue = analogRead(A0);</span></p>
   <p style="padding: 0px;"><span style="font-weight: 600; font-family: AppleSDGothicNeo-Bold;">&nbsp; // Convert the analog reading (which goes from 0 - 1023) to a voltage (0 - 5V):</span></p>
   <p style="padding: 0px;"><span style="font-weight: 600; font-family: AppleSDGothicNeo-Bold;">&nbsp; Vref = (Vin * 1023.0) / sensorValue;</span></p>
   <p style="padding: 0px;"><span style="font-weight: 600; font-family: AppleSDGothicNeo-Bold;">&nbsp; voltage = sensorValue * (Vref / 1023.0);</span></p>
   <p style="padding: 0px;"><span style="font-weight: 600; font-family: AppleSDGothicNeo-Bold;">&nbsp; // print out the value you read:</span></p>
   <p style="padding: 0px;"><span style="font-weight: 600; font-family: AppleSDGothicNeo-Bold;">&nbsp; Serial.println("A0 = "+String(sensorValue));</span></p>
   <p style="padding: 0px;"><span style="font-weight: 600; font-family: AppleSDGothicNeo-Bold;">&nbsp; Serial.println("Reference Voltage = "+String(Vref));</span></p>
   <p style="padding: 0px;"><span style="font-weight: 600; font-family: AppleSDGothicNeo-Bold;">&nbsp; Serial.println("ADC Voltage = "+String(voltage));</span></p>
   <p style="padding: 0px;"><span style="font-weight: 600; font-family: AppleSDGothicNeo-Bold;">&nbsp; delay(2000);</span></p>
   <p style="padding: 0px;"><span style="font-weight: 600; font-family: AppleSDGothicNeo-Bold;"></span></p>
   <p style="padding: 0px;"><span style="font-weight: 600; font-family: AppleSDGothicNeo-Bold;">}</span></p>
   <p style="padding: 0px;"><span style="font-weight: 600; font-family: AppleSDGothicNeo-Bold;"><br /></span></p>
   <p style="padding: 0px;"><span style="font-weight: 600; font-family: AppleSDGothicNeo-Bold;"><span class="_img  fx" thumburl="https://mblogthumb-phinf.pstatic.net/MjAxNzAzMjZfMTE2/MDAxNDkwNTA5MzMzMzA0.EjIKvVrGGZI1sK14UKnXgXmZDf26UwS4pMEKnM06WyUg.kZEm5H41nXmrbYmSa7XSo52cS8tHT3GDhtNC2mK9EwUg.JPEG.mkhee77/%EC%BA%A1%EC%B2%98vo1.JPG?type=" style="max-width: 100%;"><img src="https://mblogthumb-phinf.pstatic.net/MjAxNzAzMjZfMTE2/MDAxNDkwNTA5MzMzMzA0.EjIKvVrGGZI1sK14UKnXgXmZDf26UwS4pMEKnM06WyUg.kZEm5H41nXmrbYmSa7XSo52cS8tHT3GDhtNC2mK9EwUg.JPEG.mkhee77/%EC%BA%A1%EC%B2%98vo1.JPG?type=w2" largesrc="javascript:location.href='https://mblogthumb-phinf.pstatic.net/MjAxNzAzMjZfMTE2/MDAxNDkwNTA5MzMzMzA0.EjIKvVrGGZI1sK14UKnXgXmZDf26UwS4pMEKnM06WyUg.kZEm5H41nXmrbYmSa7XSo52cS8tHT3GDhtNC2mK9EwUg.JPEG.mkhee77/%EC%BA%A1%EC%B2%98vo1.JPG?type=w2'" id="img_3" data-top="4677" style="border: 0px; vertical-align: top; max-width: 100%;" /></span></span></p>
   <p style="padding: 0px;">-&gt; 시리얼 모니터 출력결과이다. 기준전압이 5.0V에서 4.68V로 바뀌었고</p>
   <p style="padding: 0px;">&nbsp; &nbsp; A0핀의 전압 게산결과도 4.23V에서 3.95V로 바뀌었다.</p>
   <p style="padding: 0px;"><br /></p>
   <p style="padding: 0px;"><span class="_img  fx" thumburl="https://mblogthumb-phinf.pstatic.net/MjAxNzAzMjZfMiAg/MDAxNDkwNTA5NDc2NDA3.ZkbnQ90ztCOnjvVmzOtSHGTvhbsbWnzI7TBxAg0RXP8g.yyUjAR5XLrXbD9q1lze8PhyDzsXyUrSGUPn27kdTn2Eg.JPEG.mkhee77/20170326_151907.jpg?type=" style="max-width: 100%;"><img src="https://mblogthumb-phinf.pstatic.net/MjAxNzAzMjZfMiAg/MDAxNDkwNTA5NDc2NDA3.ZkbnQ90ztCOnjvVmzOtSHGTvhbsbWnzI7TBxAg0RXP8g.yyUjAR5XLrXbD9q1lze8PhyDzsXyUrSGUPn27kdTn2Eg.JPEG.mkhee77/20170326_151907.jpg?type=w2" largesrc="javascript:location.href='https://mblogthumb-phinf.pstatic.net/MjAxNzAzMjZfMiAg/MDAxNDkwNTA5NDc2NDA3.ZkbnQ90ztCOnjvVmzOtSHGTvhbsbWnzI7TBxAg0RXP8g.yyUjAR5XLrXbD9q1lze8PhyDzsXyUrSGUPn27kdTn2Eg.JPEG.mkhee77/20170326_151907.jpg?type=w2'" id="img_4" data-top="5251" style="border: 0px; vertical-align: top; max-width: 100%;" /></span>&nbsp;</p>
   <p style="padding: 0px;">-&gt; 실제 A0핀을 테스터기로 찍어본 결과도 3.95V이다.</p>
   <p style="padding: 0px;"><br /></p>
   <p style="padding: 0px;">&lt;2017/8/24&nbsp; 내용 추가&gt;&nbsp;</p>
   <p style="padding: 0px;">아두이노의 Vin 단자나 전원어뎁터단자에 전원을 넣게되면 아두이노 내부의 +5V REG를 거치며 전압 drop이 발생하는데</p>
   <p style="padding: 0px;">이와 같은 전압 drop을 감안하여 전압을 넣어주지 않으면 기준전압은 5V 이하로 낮아지게 된다.</p>
   <p style="padding: 0px;">보통 사용하는 5V Regulator마다 다르지만 drop되는 전압값이 1V라고 했을 때, 5V (REG 출력전압) + 1V(Drop전압) = 6V 이상 공급해주어야</p>
   <p style="padding: 0px;">정상적인 5V 출력전압을 낼 수 있다. 만약 5.5V를 넣어주었다면 1V가 drop될 경우 REG의 출력전압은 4.5V가 되며, MCU의 VCC단에</p>
   <p style="padding: 0px;">4.5V가 공급되고 기준전압도 4.5V가 된다. 이를 감안하여 아두이노 홈페이지의 아두이노 SPEC 항목을 보면 입력전압범위가 7~12V로 되어있다.</p>
   <p style="padding: 0px;"><br /></p>
   <p style="padding: 0px;"><a href="http://blog.naver.com/mkhee77/221074391861" target="_blank" _foo="con_link" style="color: #005fc1; cursor: pointer; -webkit-tap-highlight-color: rgba(0, 0, 0, 0.1);">http://blog.naver.com/mkhee77/221074391861</a>&nbsp;</p>
   </div>