Answer the question
In order to leave comments, you need to log in
Timer compilation error: invalid operands of types. How to be?
Good day! I am making a timer to control a relay (arduino uno).
When checking the code, an error occurs:
Program:33: error: invalid operands of types '<unresolved overloaded function type>' and 'int' to binary 'operator<'
if(day<1||day>5||second!=0) return;
^
Program:33: error: invalid operands of types '<unresolved overloaded function type>' and 'int' to binary 'operator>'
if(day<1||day>5||second!=0) return;
^
Program:33: error: invalid operands of types '<unresolved overloaded function type>' and 'int' to binary 'operator!='
if(day<1||day>5||second!=0) return;
^
Program:34: error: invalid operands of types '<unresolved overloaded function type>' and 'int' to binary 'operator=='
flag|=(hour==8&&minute==30);
//Цепляем библиотеки
#include <DS3231.h>
#include <Wire.h>
#include <RTC.h>
#include <Time.h>
#include <TimeLib.h>
//Готово
int Rele = 7; //номер пина для реле
DS3231 Clock; //подключаем часики
bool h12; //24часовой формат
bool PM; //тоже к часикам и формату
void setup() { //запускаемся
Serial.begin(9600); //устанавливаем скорость передачи данных
Wire.begin();
digitalWrite(Rele, HIGH); //устанавливаем значение на реле - "выключено"
pinMode(Rele, OUTPUT); //устанавливаем на реле "высокий" уровень
}
void loop() { //рабочий режим/алгоритмы
Clock.setClockMode(false);
int day, hour, minute, second; //объявляем переменные
day = Clock.getDoW(); //получаем день недели
hour = Clock.getHour(h12, PM); //присваиваем часы
minute = Clock.getMinute(); //присваиваем минуты
second = Clock.getSecond(); //присваиваем секунды
}
void testmatch(){
bool flag=0;
if((day<1)||(day>5)||(second!=0)) return;
flag|=(hour==8&&minute==30);
flag|=(hour==9&&minute==15);
flag|=(hour==9&&minute==25);
flag|=(hour==10&&minute==10);
flag|=(hour==10&&minute==25);
flag|=(hour==11&&minute==10);
flag|=(hour==12&&minute==15);
flag|=(hour==12&&minute==30);
flag|=(hour==13&&minute==15);
flag|=(hour==13&&minute==25);
flag|=(hour==14&&minute==10);
flag|=(hour==14&&minute==20);
flag|=(hour==15&&minute==05);
flag|=(hour==15&&minute==25);
flag|=(hour==16&&minute==10);
flag|=(hour==16&&minute==30);
flag|=(hour==17&&minute==15);
flag|=(hour==17&&minute==25);
flag|=(hour==18&&minute==10);
flag|=(hour==18&&minute==20);
flag|=(hour==19&&minute==05);
if(!flag) return;
digitalWrite(Rele, LOW);
delay(5000);
digitalWrite(Rele, HIGH);
}
Answer the question
In order to leave comments, you need to log in
Put spaces around &&.
This code is disgusting. Convert the time to minutes and calculate the remainder of the division. It will be shorter and clearer.
You have day, minute, hour - local variables of the loop function. Make them global, or better yet, fix the architecture so that global variables are only used to pass data to interrupt handlers.
You have day, hour, minute, second variables declared inside the loop() function. Therefore, they are not visible inside the testmatch() function, so the compiler swears.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question