Доброе время суток, Подключил к своему Arduino UNO DS1302 Проблема заключается в том, что не могу установить время на чипе Скетч и скрин случившегося Код: Спойлер Код (C++): // Example sketch for interfacing with the DS1302 timekeeping chip. // // Copyright (c) 2009, Matt Sparks // All rights reserved. // // http://quadpoint.org/projects/arduino-ds1302 #include <stdio.h> #include <DS1302.h> namespace { // Set the appropriate digital I/O pin connections. These are the pin // assignments for the Arduino as well for as the DS1302 chip. See the DS1302 // datasheet: // // http://datasheets.maximintegrated.com/en/ds/DS1302.pdf const int kCePin = 2; // Chip Enable const int kIoPin = 3; // Input/Output const int kSclkPin = 4; // Serial Clock // Create a DS1302 object. DS1302 rtc(kCePin, kIoPin, kSclkPin); String dayAsString(const Time::Day day) { switch (day) { case Time::kSunday: return "Sunday"; case Time::kMonday: return "Monday"; case Time::kTuesday: return "Tuesday"; case Time::kWednesday: return "Wednesday"; case Time::kThursday: return "Thursday"; case Time::kFriday: return "Friday"; case Time::kSaturday: return "Saturday"; } return "(unknown day)"; } void printTime() { // Get the current time and date from the chip. Time t = rtc.time(); // Name the day of the week. const String day = dayAsString(t.day); // Format the time and date and insert into the temporary buffer. char buf[50]; snprintf(buf, sizeof(buf), "%s %04d-%02d-%02d %02d:%02d:%02d", day.c_str(), t.yr, t.mon, t.date, t.hr, t.min, t.sec); // Print the formatted string to serial so we can see the time. Serial.println(buf); } } // namespace void setup() { Serial.begin(9600); ; // Initialize a new chip by turning off write protection and clearing the // clock halt flag. These methods needn't always be called. See the DS1302 // datasheet for details. rtc.writeProtect(false); rtc.halt(false); // Make a new time object to set the date and time. // Sunday, September 22, 2013 at 01:38:50. Time lol(2013, 9, 22, 1, 38, 50, Time::kSunday); // Set the time and date on the chip. rtc.time(lol); } // Loop and print the time every second. void loop() { printTime(); delay(1000); } Фото с монитора: Спойлер
Если данный код из примера к Вашей библиотеке, самый простой вариант поискать другую библиотеку. К примеру на оф. сайте - http://playground.arduino.cc/Main/DS1302RTC. Там есть примеры, установка даты через Serial, пример - SetSerial, там же пример DS1302_Serial с отображением времени. Вы можете их объединить. Вот еще 1 пример - http://playground.arduino.cc/Main/DS1302, правда выполнен без библиотеки, это не всегда удобно. Можно посмотреть не только оф. источники. Так же в сети есть видео - На русском, с описанием и тестом отставания. Удачи.
Попробовал все 3 варинта, к сожалению, всё также и осталось. Часы в упор не хотят слушать компьютер и устанавливать нужную дату
Удалось найти рабочую библиотеку и всё заработало как надо https://virtuabotix-virtuabotixllc.netdna-ssl.com/core/wp-content/uploads/2014/01/virtuabotixRTC.zip
Если Вы только начинаете, старайтесь находить готовые библиотеки. И использовать в проектах готовые и опробованные решения, это значительно ускоряет разработку. Со временем придет опыт, так было у всех. Удачи в изучении.