Помогите пожалуйста, в конце скетча закоментировал условия при которых нужно включать циклы рассвет, день, закат, ночь.
//=======================================
#include <SolarCalculator.h>
#include “RTClib.h”
RTC_DS3231 rtc;
char daysOfTheWeek[7][12] = {“Sunday”, “Monday”, “Tuesday”, “Wednesday”, “Thursday”, “Friday”, “Saturday”};
void setup()
{
Serial.begin(57600);
// Date
int year = 2025;
int month = 1;
int day = 21;
// Location Orel 52.929006, 36.013051
double latitude = 52.92;
double longitude = 36.01;
int utc_offset = +3;
double transit, sunrise, sunset;
// Calculate the times of sunrise, transit, and sunset, in hours (UTC)
calcSunriseSunset(year, month, day, latitude, longitude, transit, sunrise, sunset);
// Get the approximate times (minimum program size) (iterations = 0)
//calcSunriseSunset(year, month, day, latitude, longitude, transit, sunrise, sunset, SUNRISESET_STD_ALTITUDE, 0);
// Print results
char str[6];
Serial.println(hoursToString(sunrise + utc_offset, str));
Serial.println(hoursToString(transit + utc_offset, str));
Serial.println(hoursToString(sunset + utc_offset, str));
// настройка часов
if (! rtc.begin()) {
Serial.println(“Couldn’t find RTC”);
Serial.flush();
while (1) delay(10);
}
if (rtc.lostPower()) {
Serial.println(“RTC lost power, let’s set the time!”);
// When time needs to be set on a new device, or after a power loss, the
// following line sets the RTC to the date & time this sketch was compiled
rtc.adjust(DateTime(F(DATE), F(TIME))); }
}
void loop()
{ DateTime now = rtc.now();
Serial.print(now.year(), DEC);
Serial.print('/');
Serial.print(now.month(), DEC);
Serial.print('/');
Serial.print(now.day(), DEC);
Serial.print(" (");
Serial.print(daysOfTheWeek[now.dayOfTheWeek()]);
Serial.print(") ");
Serial.print(now.hour(), DEC);
Serial.print(':');
Serial.print(now.minute(), DEC);
Serial.print(':');
Serial.print(now.second(), DEC);
Serial.println();
Serial.print(" since midnight 1/1/1970 = ");
Serial.print(now.unixtime());
Serial.print("s = ");
Serial.print(now.unixtime() / 86400L);
Serial.println("d");
// calculate a date which is 7 days, 12 hours, 30 minutes, 6 seconds into the future
DateTime future (now + TimeSpan(7,12,30,6));
Serial.print(" now + 7d + 12h + 30m + 6s: ");
Serial.print(future.year(), DEC);
Serial.print('/');
Serial.print(future.month(), DEC);
Serial.print('/');
Serial.print(future.day(), DEC);
Serial.print(' ');
Serial.print(future.hour(), DEC);
Serial.print(':');
Serial.print(future.minute(), DEC);
Serial.print(':');
Serial.print(future.second(), DEC);
Serial.println();
Serial.print("Temperature: ");
Serial.print(rtc.getTemperature());
Serial.println(" C");
Serial.println();
delay(3000);
}
// Rounded HH:mm format
char * hoursToString(double h, char *str)
{
int m = int(round(h * 60));
int hr = (m / 60) % 24;
int mn = m % 60;
str[0] = (hr / 10) % 10 + ‘0’;
str[1] = (hr % 10) + ‘0’;
str[2] = ‘:’;
str[3] = (mn / 10) % 10 + ‘0’;
str[4] = (mn % 10) + ‘0’;
str[5] = ‘\0’;
return str;
if // если время(часы минуты) = sunrise;
//включаем цикл void sunrise();
else //время(часы минуты) больше sunrise
//включем цикл void day();
if // время(часы минуты) = sunset;
// включаем цикл sunset();
else //время(часы минуты) больше sunset
//включем цикл void night();
}
void sunrise();
void day();
void sunset();
void night();