So I'm breaking down my new program into chunks and am currently writing the chunk that will:
- set RTC time
- read RTC time and serial print (soon to be lcd print when my new lcd comes in the mail)
- activate relay based on "minutes" data
The program works in that it will set time and print time but I am getting an error whenever I try to write code to activate the relay. Perhaps somebody can look at the code so far and enlighten me on the error that I keep getting.
#include <Time.h>
#include <Wire.h>
#include <DS3231RTC.h> // A simple DS3231 Library meant for use with Time.h also implements temp readings
const int RELAY1 = 22;
const int RELAY2 = 23;
const int RELAY3 = 24;
const int RELAY4 = 25;
void setup() {
Serial.begin(9600);
setTime(10,1,0,9,14,16);
}
void loop()
{
digitalClockDisplay();
delay(1000);
}
void digitalClockDisplay(){
// digital clock display of the time
Serial.print(hour());
printDigits(minute());
printDigits(second());
Serial.print(" ");
Serial.print(day());
Serial.print(" ");
Serial.print(month());
Serial.print(" ");
Serial.print(year());
Serial.print(" ");
Serial.print(RTC.getTemp()); //These last few lines are the only other change to the the Time.h example!
Serial.print((char)223);
Serial.print('C');
Serial.println();
}
void printDigits(int digits){
// utility function for digital clock display: prints preceding colon and leading 0
Serial.print(":");
if(digits < 10)
Serial.print('0');
Serial.print(digits);
}
void fanTimer(){
if ( minute >= 0 && minute < 5)
{
digitalWrite ( RELAY2, HIGH );
}
else
{
digitalWrite ( RELAY2, LOW );
}
}
ERROR:
sketch_sep14c.ino: In function 'void fanTimer()':
sketch_sep14c.ino:49:22: error: invalid operands of types '' and 'int' to binary 'operator>='
sketch_sep14c.ino:49:36: error: invalid operands of types '' and 'int' to binary 'operator<'
Error compiling.