background image

  while (Serial.available() > 0) 

  { 

    c= char(Serial.read()); 

    delay(2); 

    mark = 1; 

  } 

  //if data is all collected,then parse it 

  if (mark == 1) 

  { 

    Serial.println(comdata); 

    Serial.println(comdata.length()); 

    //parse data 

    for (int i = 0; i < comdata.length() ; i++) 

    { 

      //if the byte is ',' jump it,and parse next value 

      if (comdata[i] == ',') 

      { 

        j++; 

      } 

      else 

      { 

        rr[j] = rr[j] * 10 + (comdata[i] - '0'); 

      } 

    } 

    comdata = String(""); 

    RTC.stop(); 

    RTC.set(DS1307_SEC, rr[6]); 

    RTC.set(DS1307_MIN, rr[5]); 

    RTC.set(DS1307_HR, rr[4]); 

    RTC.set(DS1307_DOW, rr[3]); 

    RTC.set(DS1307_DATE, rr[2]); 

    RTC.set(DS1307_MTH, rr[1]); 

    RTC.set(DS1307_YR, rr[0]); 

    RTC.start(); 

Downloaded from

Arrow.com.

Downloaded from

Arrow.com.

Downloaded from

Arrow.com.

Downloaded from

Arrow.com.

Downloaded from

Arrow.com.

Отзывы: