• Witaj na Forum Arduino Polska! Zapraszamy do rejestracji!
  • Znajdziesz tutaj wiele informacji na temat hardware / software.
Witaj! Logowanie Rejestracja


Ocena wątku:
  • 0 głosów - średnia: 0
  • 1
  • 2
  • 3
  • 4
  • 5
funkcja dla Tiny RTC w celu przechowania strnga z czasem
#1
Kod:
#include <DS1307RTC.h>
String showtime;

String czas;
void setup() {
  Serial.begin(9600);    // the SERIAL baud rate
  delay(5000);
  gettime();
  delay(100);
  Serial.println(showtime);
}

void gettime(){
  tmElements_t tm;
  showtime = " ";
 
  if (RTC.read(tm)){
    showtime = "Czas: ";
    showtime += tmYearToCalendar(tm.Year);
    showtime += "/";
    showtime += tm.Month;
    showtime += "/";
    showtime += tm.Day;
    showtime += ", ";
    showtime += tm.Hour;
    showtime += ":";
    showtime += tm.Minute;
    showtime += ":";
    showtime += tm.Second;
    showtime += " .";
  }
  else {
    if (RTC.chipPresent()) {
      showtime = "The DS1307 is stopped.  Please run the SetTime";
    } else {
      showtime = "DS1307 read error!  Please check the circuitry.";
    }
  }
  showtime = "blad RTC!";
}
problem w tym ze nie mogę przechować to w zmiennej showtime, ani nie moge zrobić żeby funkcja gettime() zwracała to na zasadzie return showtime. kod się wysypuje na Serial.println();
 
Odpowiedź
  


Wiadomości w tym wątku
funkcja dla Tiny RTC w celu przechowania strnga z czasem - przez hebdzik - 14-06-2020, 20:07

Skocz do:


Przeglądający: 1 gości