okay, sorry for this I just acquaint with this.
here is whole code and fail is, that time on display is stopped during void rise(). How to correct use intettupts?
#include <TimerOne.h>
#include <Nokia5110.h>
#include <DS3231.h>
#define RST 8
#define CE 7
#define DC 6
#define DIN 5
#define CLK 4
#define BETWEEN 2579
#define DURATION 43
#define TIMES 7
#define REDPIN 9
#define GREENPIN 10
#define BLUEPIN 11
#define FADESPEED 5
LCDnokia5110 lcd(RST, CE, DC, DIN, CLK);
int Relay = 2;
int Relay2 = 3;
int temp;
unsigned long lastTime = 0;
int waitTime = 0;
int r, g, b;
int wait = 150;
DS3231 rtc(SDA, SCL);
Time t;
const int OnHour = 17;
const int OnMin = 48;
const int OffHour = 17;
const int OffMin = 49;
const int Relay2OnHour = 17;
const int Relay2OnMin = 50;
const int Relay2OffHour = 17;
const int Relay2OffMin = 51;
void setup() {
Serial.begin(9600);
rtc.begin();
pinMode(Relay, OUTPUT);
pinMode(Relay2, OUTPUT);
pinMode(REDPIN, OUTPUT);
pinMode(GREENPIN, OUTPUT);
pinMode(BLUEPIN, OUTPUT);
digitalWrite(Relay, HIGH);
digitalWrite(Relay2, HIGH);
Timer1.initialize(1000000);
Timer1.attachInterrupt(rise);
Timer1.attachInterrupt(fall);
lcd.LcdInitialise();
lcd.LcdClear();
lcd.CharSpace = 1; // nastavení velikosti mezery mezi písmeny,lze nastavit na 0, 1 či 2 body
lcd.GotoXY(70, 0);
lcd.LcdString("'C");
lcd.GotoXY(0, 1);
lcd.LcdString("Relay 1:");
lcd.GotoXY(55, 1);
lcd.LcdString("OFF");
lcd.GotoXY(0, 2);
lcd.LcdString("Relay 2:");
lcd.GotoXY(55, 2);
lcd.LcdString("OFF");
lcd.CharSpace = 0;
lcd.GotoXY(0, 3);
lcd.LcdString("Teplota:");
lcd.GotoXY(55, 3);
lcd.CharSpace = 1;
lcd.LcdString("60'C");
lcd.GotoXY(0, 44);
lcd.LcdString("PH:");
}
void loop() {
temp = rtc.getTemp();
t = rtc.getTime();
char buffer[5];
lcd.GotoXY(0, 0);
sprintf(buffer, "%2d", t.hour);
lcd.LcdString(buffer);
lcd.GotoXY(12, 0);
lcd.LcdString(":");
//==========MINUTY
lcd.GotoXY(17, 0);
sprintf(buffer, "%2d", t.min);
lcd.LcdString(buffer);
lcd.GotoXY(29, 0);
lcd.LcdString(":");
//==========SEKUNDY
lcd.GotoXY(34, 0);
sprintf(buffer, "%2d", t.sec);
lcd.LcdString(buffer);
//=========TEPLOTA elektroniky
lcd.GotoXY(57, 0);
sprintf(buffer, "%2d", temp);
lcd.LcdString(buffer);
//=========TEPLOTA elektroniky
lcd.GotoXY(57, 0);
sprintf(buffer, "%2d", temp);
lcd.LcdString(buffer);
delay(1000);
//===========================Rele LED pásik
if (t.hour == OnHour && t.min == OnMin) {
digitalWrite(Relay, LOW);
lcd.GotoXY(55, 1);
lcd.LcdString("ON ");
rise();
}
else if (t.hour == OffHour && t.min == OffMin) {
digitalWrite(Relay, HIGH);
lcd.GotoXY(55, 1);
lcd.LcdString("OFF");
}
//========================Rele Svetlo
if (t.hour == Relay2OnHour && t.min == Relay2OnMin) {
digitalWrite(Relay2, LOW);
lcd.GotoXY(55, 2);
lcd.LcdString("ON ");
fall();
}
else if (t.hour == Relay2OffHour && t.min == Relay2OffMin) {
digitalWrite(Relay2, HIGH);
lcd.GotoXY(55, 2);
lcd.LcdString("OFF");
}
}
void rise() {
g = 0;
b = 0;
for (r = 0; r <= 255; r++)
{
g = r;
if (g >= 50) {
b = b + 1;
}
analogWrite(REDPIN, r);
analogWrite(GREENPIN, g);
analogWrite(BLUEPIN, b);
Serial.print("R=");
Serial.print(r);
Serial.print("G=");
Serial.print(g);
Serial.print("B=");
Serial.print(b);
Serial.print(" | ");
delay(wait);
if(r==253) {
b=253;
}
if(r==255) {
exit(r);
}
}
}
void fall() {
g = 255;
b = 255;
for (r = 255; r >= 0; r--)
{
g = r;
if (g <= 206) {
b = b - 1;
}
analogWrite(REDPIN, r);
analogWrite(GREENPIN, g);
analogWrite(BLUEPIN, b);
Serial.print("R=");
Serial.print(r);
Serial.print("G=");
Serial.print(g);
Serial.print("B=");
Serial.print(b);
Serial.print(" | ");
delay(wait);
if(r==2) {
b=2;
}
if(r==0) {
exit(r);
}
}
}
void burka() {
if (millis() - waitTime > lastTime) // time for a new flash
{
// adjust timing params
lastTime += waitTime;
waitTime = random(BETWEEN);
analogWrite(BLUEPIN, 220);
for (int i = 0; i < random(TIMES); i++)
{
Serial.println(millis());
analogWrite(REDPIN, 255);
analogWrite(GREENPIN, 255);
analogWrite(BLUEPIN, 255),
delay(20 + random(DURATION));
analogWrite(REDPIN, 0);
analogWrite(GREENPIN, 0);
analogWrite(BLUEPIN, 0);
delay(10);
}
}
analogWrite(BLUEPIN, 5);
if (millis() - waitTime > lastTime) // time for a new flash
{
// adjust timing params
lastTime += waitTime;
waitTime = random(BETWEEN);
for (int i = 0; i < random(TIMES); i++)
{
analogWrite(BLUEPIN, 255);
delay(10 + random(DURATION));
analogWrite(BLUEPIN, 0);
delay(10);
}
}
}