Well I finally got it working. Now I just hope you might be able to make sense of this to me. It was certainly the fact that I didn't have the pinMode set to output but here is where I'm confused.
When I try to set up my relay pins as constants like so
#include <DS3232RTC.h>
#include <Time.h>
#include <Wire.h>
void setup() {
pinMode(22, OUTPUT);
pinMode(23, OUTPUT);
pinMode(24, OUTPUT);
pinMode(25, OUTPUT);
Serial.begin(9600);
setTime(10,1,0,9,14,16);
}
void loop()
{
fanTimer(); //add call to function
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((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 ( 22, HIGH );
}
else
{
digitalWrite ( 22, LOW );
}
}
I get the following error
sketch_sep15a.ino:6:1: error: expected unqualified-id before numeric constant
sketch_sep15a.ino:6:1: error: expected ',' or ';' before 'const'
Error compiling.
but if I remove the constants and express the program like this
#include <DS3232RTC.h>
#include <Time.h>
#include <Wire.h>
void setup() {
pinMode(22, OUTPUT);
pinMode(23, OUTPUT);
pinMode(24, OUTPUT);
pinMode(25, OUTPUT);
Serial.begin(9600);
setTime(10,1,0,9,14,16);
}
void loop()
{
fanTimer(); //add call to function
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((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 ( 22, HIGH );
}
else
{
digitalWrite ( 22, LOW );
}
}
It works like it should. any ideas?