<p style="box-sizing: inherit; color: #373a3c; font-family: -apple-system, BlinkMacSystemFont, &quot;Segoe UI&quot;, Roboto, &quot;Helvetica Neue&quot;, Arial, sans-serif; font-size: 16px; background-color: #ffffff; padding-top: 0px !important; padding-bottom: 0px !important;">아두이노로 데이터를 보내면 'Serial.read()'로 데이터를 읽습니다.</p>
<p style="box-sizing: inherit; color: #373a3c; font-family: -apple-system, BlinkMacSystemFont, &quot;Segoe UI&quot;, Roboto, &quot;Helvetica Neue&quot;, Arial, sans-serif; font-size: 16px; background-color: #ffffff; padding-top: 0px !important; padding-bottom: 0px !important;">그런데 문자열을 'Serial.read()'로 읽으면 한번에 한글자만 읽어집니다.</p>
<div class="SubTitle Red" style="box-sizing: inherit; width: 949px; margin: 10px 0px 5px; padding: 10px 0px; color: #373a3c; font-family: -apple-system, BlinkMacSystemFont, &quot;Segoe UI&quot;, Roboto, &quot;Helvetica Neue&quot;, Arial, sans-serif; font-size: 16px; background-color: #ffffff;">
   <div style="box-sizing: inherit; border-style: solid; border-width: 0px 0px 1px 4px; padding: 10px; margin: 0px 15px 0px 5px; border-color: #ff0000;">
      <h5 style="box-sizing: inherit; font-family: inherit; line-height: 1.1; color: inherit; margin: 0px; font-size: 18px;">1. 문자열 보내기 테스트용</h5>
      </div>
   </div>
<p style="box-sizing: inherit; color: #373a3c; font-family: -apple-system, BlinkMacSystemFont, &quot;Segoe UI&quot;, Roboto, &quot;Helvetica Neue&quot;, Arial, sans-serif; font-size: 16px; background-color: #ffffff; padding-top: 0px !important; padding-bottom: 0px !important;">일단 LED 3개를 달아봅시다,</p>
<p style="box-sizing: inherit; color: #373a3c; font-family: -apple-system, BlinkMacSystemFont, &quot;Segoe UI&quot;, Roboto, &quot;Helvetica Neue&quot;, Arial, sans-serif; font-size: 16px; background-color: #ffffff; padding-top: 0px !important; padding-bottom: 0px !important;">아웃풋 핀은 3,5,6를 사용합니다.</p>
<p style="box-sizing: inherit; color: #373a3c; font-family: -apple-system, BlinkMacSystemFont, &quot;Segoe UI&quot;, Roboto, &quot;Helvetica Neue&quot;, Arial, sans-serif; font-size: 16px; background-color: #ffffff; padding-top: 0px !important; padding-bottom: 0px !important;">(이왕이면 빨간색, 녹색, 파란색으로 세팅합시다.)</p>
<p style="box-sizing: inherit; color: #373a3c; font-family: -apple-system, BlinkMacSystemFont, &quot;Segoe UI&quot;, Roboto, &quot;Helvetica Neue&quot;, Arial, sans-serif; font-size: 16px; background-color: #ffffff; padding-top: 0px !important; padding-bottom: 0px !important;">&nbsp;</p>
<div class="SubTitle Yellow" style="box-sizing: inherit; width: 949px; margin: 10px 0px 5px; padding: 10px 0px; color: #373a3c; font-family: -apple-system, BlinkMacSystemFont, &quot;Segoe UI&quot;, Roboto, &quot;Helvetica Neue&quot;, Arial, sans-serif; font-size: 16px; background-color: #ffffff;">
   <div style="box-sizing: inherit; border-style: solid; border-width: 0px 0px 1px 4px; padding: 10px; margin: 0px 15px 0px 5px; border-color: #ffff00;">
      <h5 style="box-sizing: inherit; font-family: inherit; line-height: 1.1; color: inherit; margin: 0px; font-size: 18px;">1-1. 보드 구성</h5>
      </div>
   </div>
<p style="box-sizing: inherit; color: #373a3c; font-family: -apple-system, BlinkMacSystemFont, &quot;Segoe UI&quot;, Roboto, &quot;Helvetica Neue&quot;, Arial, sans-serif; font-size: 16px; background-color: #ffffff; padding-top: 0px !important; padding-bottom: 0px !important;">그냥 LED 3개가 달려있습니다.</p>
<p style="box-sizing: inherit; color: #373a3c; font-family: -apple-system, BlinkMacSystemFont, &quot;Segoe UI&quot;, Roboto, &quot;Helvetica Neue&quot;, Arial, sans-serif; font-size: 16px; background-color: #ffffff; padding-top: 0px !important; padding-bottom: 0px !important;">&nbsp;</p>
<p style="box-sizing: inherit; color: #373a3c; font-family: -apple-system, BlinkMacSystemFont, &quot;Segoe UI&quot;, Roboto, &quot;Helvetica Neue&quot;, Arial, sans-serif; font-size: 16px; background-color: #ffffff; padding-top: 0px !important; padding-bottom: 0px !important;"><span class="imageblock" style="box-sizing: inherit; display: inline-block; width: 316px; height: auto; max-width: 100%;"><img srcset="https://img1.daumcdn.net/thumb/R1280x0/?scode=mtistory&amp;fname=http%3A%2F%2Fcfile26.uf.tistory.com%2Fimage%2F21244B3D519643A8293202" src="https://t1.daumcdn.net/cfile/tistory/21244B3D519643A829" width="316" filename="RGB_001.png" filemime="image/jpeg" style="box-sizing: inherit; border: 0px; vertical-align: middle; max-width: 100%; display: inline-block; height: auto; padding: 0px; line-height: 1.42857; box-shadow: rgb(221, 221, 221) 0px 0px 3pt 2pt; transition: all 0.2s ease-in-out 0s;" /></span></p>
<p style="box-sizing: inherit; color: #373a3c; font-family: -apple-system, BlinkMacSystemFont, &quot;Segoe UI&quot;, Roboto, &quot;Helvetica Neue&quot;, Arial, sans-serif; font-size: 16px; background-color: #ffffff; padding-top: 0px !important; padding-bottom: 0px !important;">&nbsp;</p>
<p style="box-sizing: inherit; color: #373a3c; font-family: -apple-system, BlinkMacSystemFont, &quot;Segoe UI&quot;, Roboto, &quot;Helvetica Neue&quot;, Arial, sans-serif; font-size: 16px; background-color: #ffffff; padding-top: 0px !important; padding-bottom: 0px !important;">&nbsp;</p>
<div class="SubTitle Yellow" style="box-sizing: inherit; width: 949px; margin: 10px 0px 5px; padding: 10px 0px; color: #373a3c; font-family: -apple-system, BlinkMacSystemFont, &quot;Segoe UI&quot;, Roboto, &quot;Helvetica Neue&quot;, Arial, sans-serif; font-size: 16px; background-color: #ffffff;">
   <div style="box-sizing: inherit; border-style: solid; border-width: 0px 0px 1px 4px; padding: 10px; margin: 0px 15px 0px 5px; border-color: #ffff00;">
      <h5 style="box-sizing: inherit; font-family: inherit; line-height: 1.1; color: inherit; margin: 0px; font-size: 18px;">1-2.&nbsp;펌웨어 작성</h5>
      </div>
   </div>
<p style="box-sizing: inherit; color: #373a3c; font-family: -apple-system, BlinkMacSystemFont, &quot;Segoe UI&quot;, Roboto, &quot;Helvetica Neue&quot;, Arial, sans-serif; font-size: 16px; background-color: #ffffff; padding-top: 0px !important; padding-bottom: 0px !important;">LED를 데이터를 통해 끄고 켜고를 할것이기 때문에 'switch'문을 사용해야 합니다.</p>
<p style="box-sizing: inherit; color: #373a3c; font-family: -apple-system, BlinkMacSystemFont, &quot;Segoe UI&quot;, Roboto, &quot;Helvetica Neue&quot;, Arial, sans-serif; font-size: 16px; background-color: #ffffff; padding-top: 0px !important; padding-bottom: 0px !important;">&nbsp;</p>
<p style="box-sizing: inherit; color: #373a3c; font-family: -apple-system, BlinkMacSystemFont, &quot;Segoe UI&quot;, Roboto, &quot;Helvetica Neue&quot;, Arial, sans-serif; font-size: 16px; background-color: #ffffff; padding-top: 0px !important; padding-bottom: 0px !important;">&nbsp;</p>
<div style="box-sizing: inherit; color: #373a3c; font-family: -apple-system, BlinkMacSystemFont, &quot;Segoe UI&quot;, Roboto, &quot;Helvetica Neue&quot;, Arial, sans-serif; font-size: 16px; background-color: #ffffff;">
   <pre class="brush:cpp" style="box-sizing: inherit; overflow: auto; font-family: Menlo, Monaco, Consolas, &quot;Liberation Mono&quot;, &quot;Courier New&quot;, monospace; font-size: 14.4px; padding: 9.5px; margin-top: 0px; margin-bottom: 1rem; line-height: 1.42857; word-break: break-all; overflow-wrap: break-word; background-color: #f5f5f5; border: 1px solid rgb(204, 204, 204); border-radius: 4px;">#define LED_R 6
#define LED_G 5
#define LED_B 3
String sCommand = "";
void setup()  
{                
   Serial.begin(9600);
   pinMode(LED_R, OUTPUT);
   pinMode(LED_G, OUTPUT);
   pinMode(LED_B, OUTPUT);
}
void loop()                    
{
   if(Serial.available())
   {
     char cTemp = Serial.read();
     //char cRGB = sData;
     int nON = 255;
     switch(cTemp)
     {
       case 'R':
         digitalWrite(LED_R,HIGH);
         break;
       case 'r':
         digitalWrite(LED_R,LOW);
         break;
       case 'G':
         digitalWrite(LED_G,HIGH);
         break;
       case 'g':
         digitalWrite(LED_G,LOW);
         break;
       case 'B':
         digitalWrite(LED_B,HIGH);
         break;
       case 'b':
         digitalWrite(LED_B,LOW);
         break;
     }
     Serial.println(cTemp);
   }
   delay(100);
}
</pre>
   </div>
<p style="box-sizing: inherit; color: #373a3c; font-family: -apple-system, BlinkMacSystemFont, &quot;Segoe UI&quot;, Roboto, &quot;Helvetica Neue&quot;, Arial, sans-serif; font-size: 16px; background-color: #ffffff; padding-top: 0px !important; padding-bottom: 0px !important;">&nbsp;</p>
<p style="box-sizing: inherit; color: #373a3c; font-family: -apple-system, BlinkMacSystemFont, &quot;Segoe UI&quot;, Roboto, &quot;Helvetica Neue&quot;, Arial, sans-serif; font-size: 16px; background-color: #ffffff; padding-top: 0px !important; padding-bottom: 0px !important;">&nbsp;</p>
<p style="box-sizing: inherit; color: #373a3c; font-family: -apple-system, BlinkMacSystemFont, &quot;Segoe UI&quot;, Roboto, &quot;Helvetica Neue&quot;, Arial, sans-serif; font-size: 16px; background-color: #ffffff; padding-top: 0px !important; padding-bottom: 0px !important;">코드를 보시면 아시겠지만</p>
<p style="box-sizing: inherit; color: #373a3c; font-family: -apple-system, BlinkMacSystemFont, &quot;Segoe UI&quot;, Roboto, &quot;Helvetica Neue&quot;, Arial, sans-serif; font-size: 16px; background-color: #ffffff; padding-top: 0px !important; padding-bottom: 0px !important;">R : 빨간색 켜기</p>
<p style="box-sizing: inherit; color: #373a3c; font-family: -apple-system, BlinkMacSystemFont, &quot;Segoe UI&quot;, Roboto, &quot;Helvetica Neue&quot;, Arial, sans-serif; font-size: 16px; background-color: #ffffff; padding-top: 0px !important; padding-bottom: 0px !important;">r : 빨간색 끄기</p>
<p style="box-sizing: inherit; color: #373a3c; font-family: -apple-system, BlinkMacSystemFont, &quot;Segoe UI&quot;, Roboto, &quot;Helvetica Neue&quot;, Arial, sans-serif; font-size: 16px; background-color: #ffffff; padding-top: 0px !important; padding-bottom: 0px !important;">G : 녹색 켜기</p>
<p style="box-sizing: inherit; color: #373a3c; font-family: -apple-system, BlinkMacSystemFont, &quot;Segoe UI&quot;, Roboto, &quot;Helvetica Neue&quot;, Arial, sans-serif; font-size: 16px; background-color: #ffffff; padding-top: 0px !important; padding-bottom: 0px !important;">g : 녹색 끄기</p>
<p style="box-sizing: inherit; color: #373a3c; font-family: -apple-system, BlinkMacSystemFont, &quot;Segoe UI&quot;, Roboto, &quot;Helvetica Neue&quot;, Arial, sans-serif; font-size: 16px; background-color: #ffffff; padding-top: 0px !important; padding-bottom: 0px !important;">B : 파란색 켜기</p>
<p style="box-sizing: inherit; color: #373a3c; font-family: -apple-system, BlinkMacSystemFont, &quot;Segoe UI&quot;, Roboto, &quot;Helvetica Neue&quot;, Arial, sans-serif; font-size: 16px; background-color: #ffffff; padding-top: 0px !important; padding-bottom: 0px !important;">b : 파란색 끄기</p>
<p style="box-sizing: inherit; color: #373a3c; font-family: -apple-system, BlinkMacSystemFont, &quot;Segoe UI&quot;, Roboto, &quot;Helvetica Neue&quot;, Arial, sans-serif; font-size: 16px; background-color: #ffffff; padding-top: 0px !important; padding-bottom: 0px !important;">입니다.</p>
<p style="box-sizing: inherit; color: #373a3c; font-family: -apple-system, BlinkMacSystemFont, &quot;Segoe UI&quot;, Roboto, &quot;Helvetica Neue&quot;, Arial, sans-serif; font-size: 16px; background-color: #ffffff; padding-top: 0px !important; padding-bottom: 0px !important;">&nbsp;</p>
<div class="SubTitle Red" style="box-sizing: inherit; width: 949px; margin: 10px 0px 5px; padding: 10px 0px; color: #373a3c; font-family: -apple-system, BlinkMacSystemFont, &quot;Segoe UI&quot;, Roboto, &quot;Helvetica Neue&quot;, Arial, sans-serif; font-size: 16px; background-color: #ffffff;">
   <div style="box-sizing: inherit; border-style: solid; border-width: 0px 0px 1px 4px; padding: 10px; margin: 0px 15px 0px 5px; border-color: #ff0000;">
      <h5 style="box-sizing: inherit; font-family: inherit; line-height: 1.1; color: inherit; margin: 0px; font-size: 18px;">2. 문자열 입력해 보기</h5>
      </div>
   </div>
<p style="box-sizing: inherit; color: #373a3c; font-family: -apple-system, BlinkMacSystemFont, &quot;Segoe UI&quot;, Roboto, &quot;Helvetica Neue&quot;, Arial, sans-serif; font-size: 16px; background-color: #ffffff; padding-top: 0px !important; padding-bottom: 0px !important;">이제 아두이노 프로그램에서 '시리얼 모니터'를 열어 RGB를 입력해 봅시다.</p>
<p style="box-sizing: inherit; color: #373a3c; font-family: -apple-system, BlinkMacSystemFont, &quot;Segoe UI&quot;, Roboto, &quot;Helvetica Neue&quot;, Arial, sans-serif; font-size: 16px; background-color: #ffffff; padding-top: 0px !important; padding-bottom: 0px !important;">&nbsp;</p>
<p style="box-sizing: inherit; color: #373a3c; font-family: -apple-system, BlinkMacSystemFont, &quot;Segoe UI&quot;, Roboto, &quot;Helvetica Neue&quot;, Arial, sans-serif; font-size: 16px; background-color: #ffffff; float: none; clear: none; padding-top: 0px !important; padding-bottom: 0px !important;"><span class="imageblock" style="box-sizing: inherit; display: inline-block; width: 546px; height: auto; max-width: 100%;"><img srcset="https://img1.daumcdn.net/thumb/R1280x0/?scode=mtistory&amp;fname=http%3A%2F%2Fcfile26.uf.tistory.com%2Fimage%2F015F6A3F519643D11AFC06" src="https://t1.daumcdn.net/cfile/tistory/015F6A3F519643D11A" width="546" filename="RGB_002.png" filemime="image/jpeg" style="box-sizing: inherit; border: 0px; vertical-align: middle; max-width: 100%; display: inline-block; height: auto; padding: 0px; line-height: 1.42857; box-shadow: rgb(221, 221, 221) 0px 0px 3pt 2pt; transition: all 0.2s ease-in-out 0s;" /></span></p>
<p style="box-sizing: inherit; color: #373a3c; font-family: -apple-system, BlinkMacSystemFont, &quot;Segoe UI&quot;, Roboto, &quot;Helvetica Neue&quot;, Arial, sans-serif; font-size: 16px; background-color: #ffffff; padding-top: 0px !important; padding-bottom: 0px !important;">&nbsp;</p>
<p style="box-sizing: inherit; color: #373a3c; font-family: -apple-system, BlinkMacSystemFont, &quot;Segoe UI&quot;, Roboto, &quot;Helvetica Neue&quot;, Arial, sans-serif; font-size: 16px; background-color: #ffffff; padding-top: 0px !important; padding-bottom: 0px !important;">&nbsp;</p>
<p style="box-sizing: inherit; color: #373a3c; font-family: -apple-system, BlinkMacSystemFont, &quot;Segoe UI&quot;, Roboto, &quot;Helvetica Neue&quot;, Arial, sans-serif; font-size: 16px; background-color: #ffffff; padding-top: 0px !important; padding-bottom: 0px !important;">RGB라고 입력 했는데 R,G,B로 입력되고 있습니다.</p>
<p style="box-sizing: inherit; color: #373a3c; font-family: -apple-system, BlinkMacSystemFont, &quot;Segoe UI&quot;, Roboto, &quot;Helvetica Neue&quot;, Arial, sans-serif; font-size: 16px; background-color: #ffffff; padding-top: 0px !important; padding-bottom: 0px !important;">불도 한번에 다들어왔습니다.</p>
<p style="box-sizing: inherit; color: #373a3c; font-family: -apple-system, BlinkMacSystemFont, &quot;Segoe UI&quot;, Roboto, &quot;Helvetica Neue&quot;, Arial, sans-serif; font-size: 16px; background-color: #ffffff; padding-top: 0px !important; padding-bottom: 0px !important;">&nbsp;</p>
<p style="box-sizing: inherit; color: #373a3c; font-family: -apple-system, BlinkMacSystemFont, &quot;Segoe UI&quot;, Roboto, &quot;Helvetica Neue&quot;, Arial, sans-serif; font-size: 16px; background-color: #ffffff; padding-top: 0px !important; padding-bottom: 0px !important;">이것은 'Serial.read()'가 버퍼를 읽을때는&nbsp;무조건 한바이트씩 읽기 때문입니다.</p>
<p style="box-sizing: inherit; color: #373a3c; font-family: -apple-system, BlinkMacSystemFont, &quot;Segoe UI&quot;, Roboto, &quot;Helvetica Neue&quot;, Arial, sans-serif; font-size: 16px; background-color: #ffffff; padding-top: 0px !important; padding-bottom: 0px !important;">그리고 읽은 바이트는 제거 됩니다.</p>
<p style="box-sizing: inherit; color: #373a3c; font-family: -apple-system, BlinkMacSystemFont, &quot;Segoe UI&quot;, Roboto, &quot;Helvetica Neue&quot;, Arial, sans-serif; font-size: 16px; background-color: #ffffff; padding-top: 0px !important; padding-bottom: 0px !important;">(참고 :&nbsp;<a class="tx-link" href="http://arduino.cc/en/Serial/Read" target="_blank" style="box-sizing: inherit; background-color: transparent; color: #000000; text-decoration-line: none; touch-action: manipulation; position: relative;">arduino Reference - Serial.read()</a>)</p>
<p style="box-sizing: inherit; color: #373a3c; font-family: -apple-system, BlinkMacSystemFont, &quot;Segoe UI&quot;, Roboto, &quot;Helvetica Neue&quot;, Arial, sans-serif; font-size: 16px; background-color: #ffffff; padding-top: 0px !important; padding-bottom: 0px !important;">읽은 바이트를 제거하지 않으려면 'Serial.peek()'를 사용해야 합니다.</p>
<p style="box-sizing: inherit; color: #373a3c; font-family: -apple-system, BlinkMacSystemFont, &quot;Segoe UI&quot;, Roboto, &quot;Helvetica Neue&quot;, Arial, sans-serif; font-size: 16px; background-color: #ffffff; padding-top: 0px !important; padding-bottom: 0px !important;">(참고 :&nbsp;<a class="tx-link" href="http://arduino.cc/en/Serial/Peek" target="_blank" style="box-sizing: inherit; background-color: transparent; color: #000000; text-decoration-line: none; touch-action: manipulation; position: relative;">arduino Reference - Serial.Peek()</a>)</p>
<p style="box-sizing: inherit; color: #373a3c; font-family: -apple-system, BlinkMacSystemFont, &quot;Segoe UI&quot;, Roboto, &quot;Helvetica Neue&quot;, Arial, sans-serif; font-size: 16px; background-color: #ffffff; padding-top: 0px !important; padding-bottom: 0px !important;">&nbsp;</p>
<p style="box-sizing: inherit; color: #373a3c; font-family: -apple-system, BlinkMacSystemFont, &quot;Segoe UI&quot;, Roboto, &quot;Helvetica Neue&quot;, Arial, sans-serif; font-size: 16px; background-color: #ffffff; padding-top: 0px !important; padding-bottom: 0px !important;">그러니 'loop()'가 돌면서 나머지 버퍼를 읽기 때문에 3개가 불이 다 들어 오는 것입니다.</p>
<p style="box-sizing: inherit; color: #373a3c; font-family: -apple-system, BlinkMacSystemFont, &quot;Segoe UI&quot;, Roboto, &quot;Helvetica Neue&quot;, Arial, sans-serif; font-size: 16px; background-color: #ffffff; padding-top: 0px !important; padding-bottom: 0px !important;">&nbsp;</p>
<div class="SubTitle Red" style="box-sizing: inherit; width: 949px; margin: 10px 0px 5px; padding: 10px 0px; color: #373a3c; font-family: -apple-system, BlinkMacSystemFont, &quot;Segoe UI&quot;, Roboto, &quot;Helvetica Neue&quot;, Arial, sans-serif; font-size: 16px; background-color: #ffffff;">
   <div style="box-sizing: inherit; border-style: solid; border-width: 0px 0px 1px 4px; padding: 10px; margin: 0px 15px 0px 5px; border-color: #ff0000;">
      <h5 style="box-sizing: inherit; font-family: inherit; line-height: 1.1; color: inherit; margin: 0px; font-size: 18px;">3. 해결 방법</h5>
      </div>
   </div>
<p style="box-sizing: inherit; color: #373a3c; font-family: -apple-system, BlinkMacSystemFont, &quot;Segoe UI&quot;, Roboto, &quot;Helvetica Neue&quot;, Arial, sans-serif; font-size: 16px; background-color: #ffffff; padding-top: 0px !important; padding-bottom: 0px !important;">레퍼런스를 보니 'Serial.read()'를 반복문으로 돌리지 않으면 답이 없을듯 해서 만들려다가 그래도 뭔가 있지 않을까 해서 검색 했는데....</p>
<p style="box-sizing: inherit; color: #373a3c; font-family: -apple-system, BlinkMacSystemFont, &quot;Segoe UI&quot;, Roboto, &quot;Helvetica Neue&quot;, Arial, sans-serif; font-size: 16px; background-color: #ffffff; padding-top: 0px !important; padding-bottom: 0px !important;">반복문 돌려야 한답니다 ㅎㅎㅎ;;</p>
<p style="box-sizing: inherit; color: #373a3c; font-family: -apple-system, BlinkMacSystemFont, &quot;Segoe UI&quot;, Roboto, &quot;Helvetica Neue&quot;, Arial, sans-serif; font-size: 16px; background-color: #ffffff; padding-top: 0px !important; padding-bottom: 0px !important;">(참고 :&nbsp;stackoverflow -&nbsp;<a class="tx-link" href="http://stackoverflow.com/questions/5697047/convert-serial-read-into-a-useable-string-using-arduino" target="_blank" style="box-sizing: inherit; background-color: transparent; color: #000000; text-decoration-line: none; touch-action: manipulation; position: relative;">Convert serial.read() into a useable string using Arduino?</a>&nbsp;)</p>
<p style="box-sizing: inherit; color: #373a3c; font-family: -apple-system, BlinkMacSystemFont, &quot;Segoe UI&quot;, Roboto, &quot;Helvetica Neue&quot;, Arial, sans-serif; font-size: 16px; background-color: #ffffff; padding-top: 0px !important; padding-bottom: 0px !important;">&nbsp;</p>
<p style="box-sizing: inherit; color: #373a3c; font-family: -apple-system, BlinkMacSystemFont, &quot;Segoe UI&quot;, Roboto, &quot;Helvetica Neue&quot;, Arial, sans-serif; font-size: 16px; background-color: #ffffff; padding-top: 0px !important; padding-bottom: 0px !important;">원리는 간단합니다.</p>
<p style="box-sizing: inherit; color: #373a3c; font-family: -apple-system, BlinkMacSystemFont, &quot;Segoe UI&quot;, Roboto, &quot;Helvetica Neue&quot;, Arial, sans-serif; font-size: 16px; background-color: #ffffff; padding-top: 0px !important; padding-bottom: 0px !important;">'Serial.read()'가 한바이트씩 읽는 다고 하니 반복문으로 버퍼의 모든 값을 다읽을때 까지 돌리고 그값을 'String'에 저장하면 아두이노 보드로 문자열을 보낼 수 있습니다.</p>
<p style="box-sizing: inherit; color: #373a3c; font-family: -apple-system, BlinkMacSystemFont, &quot;Segoe UI&quot;, Roboto, &quot;Helvetica Neue&quot;, Arial, sans-serif; font-size: 16px; background-color: #ffffff; padding-top: 0px !important; padding-bottom: 0px !important;">&nbsp;</p>
<div class="SubTitle Yellow" style="box-sizing: inherit; width: 949px; margin: 10px 0px 5px; padding: 10px 0px; color: #373a3c; font-family: -apple-system, BlinkMacSystemFont, &quot;Segoe UI&quot;, Roboto, &quot;Helvetica Neue&quot;, Arial, sans-serif; font-size: 16px; background-color: #ffffff;">
   <div style="box-sizing: inherit; border-style: solid; border-width: 0px 0px 1px 4px; padding: 10px; margin: 0px 15px 0px 5px; border-color: #ffff00;">
      <h5 style="box-sizing: inherit; font-family: inherit; line-height: 1.1; color: inherit; margin: 0px; font-size: 18px;">3-1. 펌웨어 수정</h5>
      </div>
   </div>
<p style="box-sizing: inherit; color: #373a3c; font-family: -apple-system, BlinkMacSystemFont, &quot;Segoe UI&quot;, Roboto, &quot;Helvetica Neue&quot;, Arial, sans-serif; font-size: 16px; background-color: #ffffff; padding-top: 0px !important; padding-bottom: 0px !important;">일단 문자열로 컨트롤 할만한 데이터로 바꿔야 하니까 RGB를 웹에서 처럼 0~255까지 값을 이용하여 밝기를 조절해 봅시다.</p>
<p style="box-sizing: inherit; color: #373a3c; font-family: -apple-system, BlinkMacSystemFont, &quot;Segoe UI&quot;, Roboto, &quot;Helvetica Neue&quot;, Arial, sans-serif; font-size: 16px; background-color: #ffffff; padding-top: 0px !important; padding-bottom: 0px !important;">입력데이터는 '255255255' 이런 형태로 RGB값을 3자리씩 총 9자리를 받아 밝기를 조절하는 것입니다.</p>
<p style="box-sizing: inherit; color: #373a3c; font-family: -apple-system, BlinkMacSystemFont, &quot;Segoe UI&quot;, Roboto, &quot;Helvetica Neue&quot;, Arial, sans-serif; font-size: 16px; background-color: #ffffff; padding-top: 0px !important; padding-bottom: 0px !important;">&nbsp;</p>
<p style="box-sizing: inherit; color: #373a3c; font-family: -apple-system, BlinkMacSystemFont, &quot;Segoe UI&quot;, Roboto, &quot;Helvetica Neue&quot;, Arial, sans-serif; font-size: 16px; background-color: #ffffff; padding-top: 0px !important; padding-bottom: 0px !important;">&nbsp;</p>
<div style="box-sizing: inherit; color: #373a3c; font-family: -apple-system, BlinkMacSystemFont, &quot;Segoe UI&quot;, Roboto, &quot;Helvetica Neue&quot;, Arial, sans-serif; font-size: 16px; background-color: #ffffff;">
   <pre class="brush:c" style="box-sizing: inherit; overflow: auto; font-family: Menlo, Monaco, Consolas, &quot;Liberation Mono&quot;, &quot;Courier New&quot;, monospace; font-size: 14.4px; padding: 9.5px; margin-top: 0px; margin-bottom: 1rem; line-height: 1.42857; word-break: break-all; overflow-wrap: break-word; background-color: #f5f5f5; border: 1px solid rgb(204, 204, 204); border-radius: 4px;">#define LED_R 6
#define LED_G 5
#define LED_B 3
//한바이트 데이터를 임시 저장
char cTemp;
//완성된 명령어
String sCommand = "";
String sTemp = "";
void setup()  
{                
   pinMode(LED_R, OUTPUT);
   pinMode(LED_G, OUTPUT);
   pinMode(LED_B, OUTPUT);
}
void loop()                    
{
   sCommand = "";
   while(Serial.available())
   {
     cTemp = Serial.read();
     sCommand.concat(cTemp);
   }
   //완성된 데이터가 있는지 확인 한다.
   if(sCommand != "" )
   {
     //완성된 데이터가 있다.
     char cTempData[4];
     sCommand.substring(0, 3).toCharArray(cTempData, 4);
     int nR = atoi(cTempData);
     sCommand.substring(3, 6).toCharArray(cTempData, 4);
     int nG = atoi(cTempData);
     sCommand.substring(6, 9).toCharArray(cTempData, 4);
     int nB = atoi(cTempData);
     digitalWrite(LED_R, nR);
     digitalWrite(LED_G, nG);
     digitalWrite(LED_B, nB);
     Serial.println(sCommand + ":" + nR + "," + nG + "," + nB ); 
   }
   delay(100);
}
</pre>
   </div>
<p style="box-sizing: inherit; color: #373a3c; font-family: -apple-system, BlinkMacSystemFont, &quot;Segoe UI&quot;, Roboto, &quot;Helvetica Neue&quot;, Arial, sans-serif; font-size: 16px; background-color: #ffffff; padding-top: 0px !important; padding-bottom: 0px !important;">&nbsp;</p>
<p style="box-sizing: inherit; color: #373a3c; font-family: -apple-system, BlinkMacSystemFont, &quot;Segoe UI&quot;, Roboto, &quot;Helvetica Neue&quot;, Arial, sans-serif; font-size: 16px; background-color: #ffffff; padding-top: 0px !important; padding-bottom: 0px !important;">&nbsp;</p>
<p style="box-sizing: inherit; color: #373a3c; font-family: -apple-system, BlinkMacSystemFont, &quot;Segoe UI&quot;, Roboto, &quot;Helvetica Neue&quot;, Arial, sans-serif; font-size: 16px; background-color: #ffffff; padding-top: 0px !important; padding-bottom: 0px !important;">이제 시리얼 모니터를 열어 '120250100'같이 값을 입력해 봅시다.</p>
<p style="box-sizing: inherit; color: #373a3c; font-family: -apple-system, BlinkMacSystemFont, &quot;Segoe UI&quot;, Roboto, &quot;Helvetica Neue&quot;, Arial, sans-serif; font-size: 16px; background-color: #ffffff; padding-top: 0px !important; padding-bottom: 0px !important;">&nbsp;</p>
<p style="box-sizing: inherit; color: #373a3c; font-family: -apple-system, BlinkMacSystemFont, &quot;Segoe UI&quot;, Roboto, &quot;Helvetica Neue&quot;, Arial, sans-serif; font-size: 16px; background-color: #ffffff; float: none; clear: none; padding-top: 0px !important; padding-bottom: 0px !important;"><span class="imageblock" style="box-sizing: inherit; display: inline-block; width: 730px; height: auto; max-width: 100%;"><img srcset="https://img1.daumcdn.net/thumb/R1280x0/?scode=mtistory&amp;fname=http%3A%2F%2Fcfile8.uf.tistory.com%2Fimage%2F2147734651964FF609FFAE" src="https://t1.daumcdn.net/cfile/tistory/2147734651964FF609" width="730" filename="strToint.png" filemime="image/jpeg" style="box-sizing: inherit; border: 0px; vertical-align: middle; max-width: 100%; display: inline-block; height: auto; padding: 0px; line-height: 1.42857; box-shadow: rgb(221, 221, 221) 0px 0px 3pt 2pt; transition: all 0.2s ease-in-out 0s; cursor: pointer;" /></span></p>
<p style="box-sizing: inherit; color: #373a3c; font-family: -apple-system, BlinkMacSystemFont, &quot;Segoe UI&quot;, Roboto, &quot;Helvetica Neue&quot;, Arial, sans-serif; font-size: 16px; background-color: #ffffff; padding-top: 0px !important; padding-bottom: 0px !important;">&nbsp;</p>
<p style="box-sizing: inherit; color: #373a3c; font-family: -apple-system, BlinkMacSystemFont, &quot;Segoe UI&quot;, Roboto, &quot;Helvetica Neue&quot;, Arial, sans-serif; font-size: 16px; background-color: #ffffff; padding-top: 0px !important; padding-bottom: 0px !important;">&nbsp;</p>
<p style="box-sizing: inherit; color: #373a3c; font-family: -apple-system, BlinkMacSystemFont, &quot;Segoe UI&quot;, Roboto, &quot;Helvetica Neue&quot;, Arial, sans-serif; font-size: 16px; background-color: #ffffff; padding-top: 0px !important; padding-bottom: 0px !important;">아래 코드를 통해 버퍼에 있는 값을 한번에 읽어 올 수 있습니다.</p>
<div style="box-sizing: inherit; color: #373a3c; font-family: -apple-system, BlinkMacSystemFont, &quot;Segoe UI&quot;, Roboto, &quot;Helvetica Neue&quot;, Arial, sans-serif; font-size: 16px; background-color: #ffffff;">
   <pre class="brush:c" style="box-sizing: inherit; overflow: auto; font-family: Menlo, Monaco, Consolas, &quot;Liberation Mono&quot;, &quot;Courier New&quot;, monospace; font-size: 14.4px; padding: 9.5px; margin-top: 0px; margin-bottom: 1rem; line-height: 1.42857; word-break: break-all; overflow-wrap: break-word; background-color: #f5f5f5; border: 1px solid rgb(204, 204, 204); border-radius: 4px;">   while(Serial.available())
   {
     cTemp = Serial.read();
     sCommand.concat(cTemp);
   }
</pre>
   </div>
<p style="box-sizing: inherit; color: #373a3c; font-family: -apple-system, BlinkMacSystemFont, &quot;Segoe UI&quot;, Roboto, &quot;Helvetica Neue&quot;, Arial, sans-serif; font-size: 16px; background-color: #ffffff; padding-top: 0px !important; padding-bottom: 0px !important;">&nbsp;</p>
<p style="box-sizing: inherit; color: #373a3c; font-family: -apple-system, BlinkMacSystemFont, &quot;Segoe UI&quot;, Roboto, &quot;Helvetica Neue&quot;, Arial, sans-serif; font-size: 16px; background-color: #ffffff; padding-top: 0px !important; padding-bottom: 0px !important;">&nbsp;</p>
<p style="box-sizing: inherit; color: #373a3c; font-family: -apple-system, BlinkMacSystemFont, &quot;Segoe UI&quot;, Roboto, &quot;Helvetica Neue&quot;, Arial, sans-serif; font-size: 16px; background-color: #ffffff; padding-top: 0px !important; padding-bottom: 0px !important;">이렇게 읽어온 값은 원하는 대로 사용하시면 됩니다.</p>
<p style="box-sizing: inherit; color: #373a3c; font-family: -apple-system, BlinkMacSystemFont, &quot;Segoe UI&quot;, Roboto, &quot;Helvetica Neue&quot;, Arial, sans-serif; font-size: 16px; background-color: #ffffff; padding-top: 0px !important; padding-bottom: 0px !important;">샘플 코드에서는 3자리씩 잘라서 숫자로 바꾸고 있습니다.</p>
<p style="box-sizing: inherit; color: #373a3c; font-family: -apple-system, BlinkMacSystemFont, &quot;Segoe UI&quot;, Roboto, &quot;Helvetica Neue&quot;, Arial, sans-serif; font-size: 16px; background-color: #ffffff; padding-top: 0px !important; padding-bottom: 0px !important;">(참고 :&nbsp;<a class="tx-link" href="http://blog.danggun.net/1771" target="_blank" style="box-sizing: inherit; background-color: transparent; color: #000000; text-decoration-line: none; touch-action: manipulation; position: relative;">[Arduino] String를 int로 변환 하기</a>)</p>
<p style="box-sizing: inherit; color: #373a3c; font-family: -apple-system, BlinkMacSystemFont, &quot;Segoe UI&quot;, Roboto, &quot;Helvetica Neue&quot;, Arial, sans-serif; font-size: 16px; background-color: #ffffff; padding-top: 0px !important; padding-bottom: 0px !important;">&nbsp;&nbsp;</p>
<div class="SubTitle Blue" style="box-sizing: inherit; width: 949px; margin: 10px 0px 5px; padding: 10px 0px; color: #373a3c; font-family: -apple-system, BlinkMacSystemFont, &quot;Segoe UI&quot;, Roboto, &quot;Helvetica Neue&quot;, Arial, sans-serif; font-size: 16px; background-color: #ffffff;">
   <div style="box-sizing: inherit; border-style: solid; border-width: 0px 0px 1px 4px; padding: 10px; margin: 0px 15px 0px 5px; border-color: #0000ff;">
      <h5 style="box-sizing: inherit; font-family: inherit; line-height: 1.1; color: inherit; margin: 0px; font-size: 18px;">마무리</h5>
      </div>
   </div>
<p style="box-sizing: inherit; color: #373a3c; font-family: -apple-system, BlinkMacSystemFont, &quot;Segoe UI&quot;, Roboto, &quot;Helvetica Neue&quot;, Arial, sans-serif; font-size: 16px; background-color: #ffffff; padding-top: 0px !important; padding-bottom: 0px !important;">생각보다 버퍼값은 믿을만 하지 않습니다.</p>
<p style="box-sizing: inherit; color: #373a3c; font-family: -apple-system, BlinkMacSystemFont, &quot;Segoe UI&quot;, Roboto, &quot;Helvetica Neue&quot;, Arial, sans-serif; font-size: 16px; background-color: #ffffff; padding-top: 0px !important; padding-bottom: 0px !important;">이것은 반대로 컴퓨터로 데이터를 보낼때도 같죠.</p>
<p style="box-sizing: inherit; color: #373a3c; font-family: -apple-system, BlinkMacSystemFont, &quot;Segoe UI&quot;, Roboto, &quot;Helvetica Neue&quot;, Arial, sans-serif; font-size: 16px; background-color: #ffffff; padding-top: 0px !important; padding-bottom: 0px !important;">&nbsp;</p>
<p style="box-sizing: inherit; color: #373a3c; font-family: -apple-system, BlinkMacSystemFont, &quot;Segoe UI&quot;, Roboto, &quot;Helvetica Neue&quot;, Arial, sans-serif; font-size: 16px; background-color: #ffffff; padding-top: 0px !important; padding-bottom: 0px !important;">값이 정확하게 한줄이 다 들어올지는 모른다는 뜻입니다.</p>
<p style="box-sizing: inherit; color: #373a3c; font-family: -apple-system, BlinkMacSystemFont, &quot;Segoe UI&quot;, Roboto, &quot;Helvetica Neue&quot;, Arial, sans-serif; font-size: 16px; background-color: #ffffff; padding-top: 0px !important; padding-bottom: 0px !important;">명렁어를 만들때는 보통 글자수를 설정하여 그만큼 읽어 들이거나 시작문자와 끝문자를 만들어 판단합니다.</p>
<p style="box-sizing: inherit; color: #373a3c; font-family: -apple-system, BlinkMacSystemFont, &quot;Segoe UI&quot;, Roboto, &quot;Helvetica Neue&quot;, Arial, sans-serif; font-size: 16px; background-color: #ffffff; padding-top: 0px !important; padding-bottom: 0px !important;">그런데 이렇게 한줄이 정확한지 알기 힘들때는 시작문자와 끝문자를 데이터의 처음과 끝에 붙여 보내는 것이 좋습니다.</p>
<p style="box-sizing: inherit; color: #373a3c; font-family: -apple-system, BlinkMacSystemFont, &quot;Segoe UI&quot;, Roboto, &quot;Helvetica Neue&quot;, Arial, sans-serif; font-size: 16px; background-color: #ffffff; padding-top: 0px !important; padding-bottom: 0px !important;">&nbsp;</p>
<p style="box-sizing: inherit; color: #373a3c; font-family: -apple-system, BlinkMacSystemFont, &quot;Segoe UI&quot;, Roboto, &quot;Helvetica Neue&quot;, Arial, sans-serif; font-size: 16px; background-color: #ffffff; padding-top: 0px !important; padding-bottom: 0px !important;">============================================================================</p>
<table width="100%" border="0" align="center" cellpadding="4" cellspacing="0" style="font-family: 굴림;">
   <tbody>
      <tr>
         <td colspan="2" style="color: #222222;">
            <table width="100%" cellpadding="5">
               <tbody>
                  <tr>
                     <td class="lh" height="100" style="color: #222222; line-height: 18px; word-break: break-all;"><span class="content" style="color: #404040;">#include &lt;EEPROM.h&gt;&nbsp;<br /><br />void setup() {&nbsp;<br />&nbsp; Serial.begin(9600);&nbsp;<br />}&nbsp;<br /><br />char input, inputData[4];&nbsp;<br />String sCommand;&nbsp;<br />int value;&nbsp;<br /><br />void loop() {&nbsp;<br />&nbsp; sCommand = "";&nbsp;<br />&nbsp; while(Serial.available()) {&nbsp;<br />&nbsp; &nbsp; input = Serial.read();&nbsp;<br />&nbsp; &nbsp; sCommand.concat(input);&nbsp;<br />&nbsp; }&nbsp;<br />&nbsp;&nbsp;<br />&nbsp; if(sCommand != "") {&nbsp; &nbsp; //완성된 데이터가 있는지 확인&nbsp;<br />&nbsp; &nbsp; sCommand.substring(0, 3).toCharArray(inputData, 4);&nbsp;<br />&nbsp; &nbsp; value = atoi(inputData);&nbsp; &nbsp;&nbsp;<br />&nbsp; &nbsp; writeEEPROM(value);&nbsp;<br />&nbsp; &nbsp; //readEEPROM(value);&nbsp;<br />&nbsp; }&nbsp;<br />&nbsp;&nbsp;<br />&nbsp; delay(500);&nbsp;<br />}&nbsp;<br /><br />void writeEEPROM(int a) {&nbsp;<br />&nbsp; EEPROM.write(0, a);&nbsp;<br />&nbsp; readEEPROM(0);&nbsp;<br />}&nbsp;<br /><br />void readEEPROM(int a) {&nbsp;<br />&nbsp; int val = EEPROM.read(a);&nbsp;<br />&nbsp; Serial.print("Address[");&nbsp;<br />&nbsp; Serial.print(a);&nbsp;<br />&nbsp; Serial.print("] : ");&nbsp;<br />&nbsp; Serial.print(val);&nbsp;<br />&nbsp; Serial.print("\n");&nbsp;<br />}</span><a href="http://geoworld.cafe24.com/gnu3/?doc=bbs/gnuboard.php&amp;bo_table=Computer&amp;page=7&amp;wr_id=31122" style="text-decoration-line: none; color: #3a4e40;" target="_blank"></a><a href="http://geoworld.cafe24.com/gnu3/?doc=bbs/gnuboard.php&amp;bo_table=Computer&amp;page=7&amp;wr_id=31122" style="text-decoration-line: none; color: #3a4e40;" target="_blank"></a></td>
                     </tr>
                  <tr>
                     <td style="color: #222222;"></td>
                     </tr>
                  </tbody>
               </table>
            </td>
         </tr>
      </tbody>
   </table>
<p style="box-sizing: inherit; color: #373a3c; font-family: -apple-system, BlinkMacSystemFont, &quot;Segoe UI&quot;, Roboto, &quot;Helvetica Neue&quot;, Arial, sans-serif; font-size: 16px; background-color: #ffffff; padding-top: 0px !important; padding-bottom: 0px !important;"><br style="color: #222222; font-family: 굴림; font-size: 12px;" /></p>
<table width="100%" align="center" cellpadding="10" cellspacing="0" border="0" bgcolor="#E6EFFF" style="font-family: 굴림;">
   <tbody>
      <tr>
         <td align="center" style="color: #222222;">
            <table width="100%" cellpadding="0" cellspacing="0" bgcolor="#FFFFFF" border="0">
               <tbody>
                  <tr>
                     <td height="35" style="color: #222222;">&nbsp;&nbsp;이름 :&nbsp;<b>geoworld</b>&nbsp;&nbsp;</td>
                     </tr>
                  </tbody>
               </table>
            </td>
         </tr>
      </tbody>
   </table>